Month: July 2020

HTML Checkbox Adding and Removing Table Row

Here’s the JavaScript code I ended up using to add and remove rows from a table based on a checkbox selection (and only allowing one checkbox per group to be selected). The biggest change is that I added a name and ID to my TR for easier identification.

$(document).on("change", "input[type='checkbox']", function () {
    var $objCheckbox = $(this);
    if ($objCheckbox.is(":checked")) {			// When checked, deactivate other checkboxes and add to sets to create table
        var objCheckboxGroup = "input:checkbox[tableselector='" + $objCheckbox.attr("tableselector") + "']";

        $(objCheckboxGroup).prop("disabled", true);
        $objCheckbox.prop("disabled", false);		// Allow checked box to be unchecked

        addSetToCreatingTable($objCheckbox.attr("setname"), $objCheckbox.attr("settype"), $objCheckbox.attr("goodcircuits") + "|" + $objCheckbox.attr("value"), $objCheckbox.attr("tableselector"));

    }
    else {							// When unchecked, active checkboxes and remove from sets to create table
        var objCheckboxGroup = "input:checkbox[name='" + $objCheckbox.attr("name") + "']";
        $(objCheckboxGroup).prop("disabled", false);	

        $("#" + $objCheckbox.attr('tableselector')).each(function(){ $(this).remove();})
}
});

What Can I sudo?

Some 90% of my Linux experience is on servers where I have root or root-equivalent access (i.e. I can sudo anything). In those cases, ‘what can I run under sudo’ was never a question. And I’d use something like “sudo less /etc/sudoers” to inspect what someone else was able to run when they questioned their access. In my new position, we have a lot of servers that we own too — the Engineering IT support group lets us spin up our own VMs, do whatever we want (within reason). But we have a few IT-managed servers with very restricted rights. And the commands I would use to perform functions (think systemctl restart httpd) aren’t in my sudoers access list. Luckily you can list out what you can run under sudo:

$ sudo -l
[sudo] password for useraccount:
Matching Defaults entries for useraccount on this host:
syslog=auth, loglinelen=0, syslog_goodpri=info, syslog_badpri=err,
logfile=/var/log/sudo.log

User useraccount may run the following commands on this host:
(ALL) /opt/lampp/lampp start, (ALL) /opt/lampp/lampp stop, (ALL)
/opt/lampp/lampp restart, (ALL) /usr/sbin/apachectl

And that is how I know to use apachectl instead of systemctl.

HTML Checkboxes To Add and Remove Values from Table

I am creating a web form where the user input sometimes cannot be resolved to a unique value. In those cases, I present the user a set of checkboxes with the options (yes, a radio button makes more sense because you can only select one. But I hate that radio buttons change selection when you hit an arrow key.).

When a selection is made, I need to (1) deactivate the checkboxes for the other options when a checkbox in the group is selected and (2) add information to a data table that is used in subsequent activities.

When a selection is cleared, I need to (1) activate the checkboxes within the group and (2) remove the right row from the data table.

Below is the HTML code that achieves this. Now I just need to map this test page into the actual web code. There’s a post with the actual code I ended up using in production too.

<html>
<head><title>Adding And Removing From Table</title></head>
<body>

<div name="divCircuitClarifications" id="divCircuitClarifications">
  <h3>My-Sample-Circuit-A</h3>
    <input type="checkbox" value="123" tableselector="SampleCircuitA" name="SampleCircuitA[]" /><label>123</label>
    <input type="checkbox" value="234" tableselector="SampleCircuitA" name="SampleCircuitA[]" /><label>234</label>
    <input type="checkbox" value="345" tableselector="SampleCircuitA" name="SampleCircuitA[]" /><label>345</label>
<P>
  <h3>My-Sample-Circuit-B</h3>
    <input type="checkbox" value="abc" tableselector="SampleCircuitB" name="SampleCircuitB[]" /><label>abc</label>
    <input type="checkbox" value="bcd" tableselector="SampleCircuitB" name="SampleCircuitB[]" /><label>bcd</label>
    <input type="checkbox" value="cde" tableselector="SampleCircuitB" name="SampleCircuitB[]" /><label>cde</label>
<P>
  <h3>My-Sample-Circuit-C</h3>
    <input type="checkbox" value="Cabc" tableselector="SampleCircuitC" name="SampleCircuitC[]" /><label>abc</label>
    <input type="checkbox" value="Cbcd" tableselector="SampleCircuitC" name="SampleCircuitC[]" /><label>bcd</label>
    <input type="checkbox" value="Ccde" tableselector="SampleCircuitC" name="SampleCircuitC[]" /><label>cde</label>
<P>
</div>

<div id="divResultTable" name="divResultTable">
<table border="1" padding="1" name="tableSetsToCreate" id="tableSetsToCreate">
	<thead><tr><th>ECCKT</th><th>Circuit ID</th></tr></thead>
	<tbody></tbody>
</table>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script>
	$("input:checkbox").on('click', function() {
	  	var $objCheckbox = $(this);
	  	if ($objCheckbox.is(":checked")) {			// When checked, deactivate other checkboxes and add to sets to create table
	    		var objCheckboxGroup = "input:checkbox[tableselector='" + $objCheckbox.attr("tableselector") + "']";
	
	    		$(objCheckboxGroup).prop("disabled", true);
	    		$objCheckbox.prop("disabled", false);		// Allow checked box to be unchecked

	                var strTableRowString = '<tr><td>' + $objCheckbox.attr("tableselector") + '</td><td>' + $objCheckbox.val() + '</td>\n';
	                $('#tableSetsToCreate tbody').append(strTableRowString);
	  	}
		else {							// When unchecked, active checkboxes and remove from sets to create table
	    		var objCheckboxGroup = "input:checkbox[name='" + $objCheckbox.attr("name") + "']";
	    		$(objCheckboxGroup).prop("disabled", false);	

			$("tr:contains('" + $objCheckbox.attr('tableselector') + "')").each(function(){ $(this).remove();})
  		}
	});
</script>
</body>



2020 Garden Update – Late July

It’s almost time to plant the broccoli, brussle sprouts, and kale! We’ve gotten a few harvests from the bush beans (and I planted more seeds a few weeks ago), and the wall of pole beans is covered in flowers. Anya and I have been snacking on pea leaf microgreens (and macrogreens!) — and rabbits apparently love pea plants above any other plant. The little bed of microgreens seems to have saved the rest of my garden from nibbles. The corn is almost as tall as I am, and the cucumber plants are covering the A-frame. Tiny peppers are starting to form on the plans

And I’ve got dozens of green tomatoes

It looks like moving the garden to a sunnier spot has been a huge improvement in production.

Next year,I want to adjust the planting schedule:

March: Start the peppers, tomatoes, watermelon, pumpkins, squash, and cantaloupe indoors. Plant snow peas outdoors.

Late April: Start the corn indoors.

Mid/late May: Plant the plants that have been growing since March. Sprinkle carrot seeds around the tomato plants — that worked quite well as I’ve never had carrots grow before. Plant the bush and pole beans outdoors.

June: Plant the corn outside. Start the broccoli, kale, cabbage, brussel sprouts, and cauliflower indoors.

July: Plant second round of bush beans outdoors.

August: Plant broccoli, kale, cabbage, brussel sprouts, and cauliflower

Web Stats

Since my website has a lot of information about Microsoft Teams, I can see when a lot of new Teams users came online during the lockdown. Now that people are returning to offices (and, I expect, are more familiar with the platform), I’m starting to see fewer search engine referrals. But I’m still 3-4x the numbers I’d seen pre-lockdown.

Oracle – LISTAGG

I needed to collapse multiple rows into a single row — the circuits within a diversity set are stored within the ds_dvrsty_set_circuit table as individual rows & the ds_dvrsty_set_id links the multiple rows. What I wanted was a set ID, set name, and the list of circuits within the set.

To accomplish this, I found LISTAGG which is a little bit like STUFF in MSSQL. This query produces a single row for each diversity set that contains the set ID, the set name, and a comma delimited list of set members.

SELECT
     ds_dvrsty_set_circuit.ds_dvrsty_set_id,
     (select ds_dvrsty_set.ds_dvrsty_set_nm from ds_dvrsty_set where ds_dvrsty_set_id = ds_dvrsty_set_circuit.ds_dvrsty_set_id) as set_name,
     LISTAGG(ds_dvrsty_set_circuit.circuit_design_id,  ',') WITHIN GROUP(ORDER BY ds_dvrsty_set_circuit.ds_dvrsty_set_id) AS member_circuits
FROM
     ds_dvrsty_set_circuit
     left outer join ds_dvrsty_set on ds_dvrsty_set.ds_dvrsty_set_id = ds_dvrsty_set_circuit.DS_DVRSTY_SET_ID
WHERE
     ds_dvrsty_set_circuit.ds_dvrsty_set_id in (select distinct ds_dvrsty_set_id from ds_dvrsty_set_circuit where circuit_design_id in (14445678, 5078901) )
AND
     ds_dvrsty_set.ds_dvrsty_set_nm like '43%'
GROUP BY
     ds_dvrsty_set_circuit.ds_dvrsty_set_id
ORDER BY
     ds_dvrsty_set_circuit.ds_dvrsty_set_id;

Voila — exactly what I needed. If the searched circuit design IDs appear in more than one set, there is a new row for each set ID.

BZA v BZA

the letter sent to homeowners to advise them of public hearings contradicts what the BZA says at the start of the meeting. I know it’s a form letter (and it’s used in many townships) and the spiel at the start of the meeting is some fixed text … but seems like the instructions int he letter can deprive homeowners of their right to testify before the Board. In the form letter, you are advised that you can attend the public hearing at such-and-such a date or submit a letter to the Board.

Sounds great. Except the beginning spiel that’s read at every public hearing says that Board members are not to consider as testimony any written correspondence that is not under oath. Oh, you had to write special letter in order for it to be given any consideration.

The spiel goes on to say that, while properly constructed letters can be considered testimony they should be given lower weight because the submitter is not available for cross-examination. That part didn’t make it to any minutes I’ve seen, but I’ve heard the chairperson say it. She, in fact, got rather curt with me for conveying exactly what she said at the beginning of the meeting to an employee of the Metro Parks when they submitted an e-mail with their opinion on a variance request. I don’t know which is true — maybe they’re giving equal weight to a written correspondence as they are to in-person testimony [this is the claim the chairperson made to me, how dare I tell the Board what they did and did not consider!] in which case the spiel at the start of the meeting should be reworded. Maybe they’re only giving consideration to sworn letters — in which case the public notice should tell you to send a sworn (or whatever) letter. Maybe a letter is basically ignored, in which case it should not be offered as an equally valid path for presenting your beliefs to the BZA.

The Proliferation of Misinformation

A friend mentioned that Madonna has jumped on the demon-sperm-doctor’s ‘a cure exists’ train. To which someone replied “who cares?” … which is a reasonable gut reaction. Some celebrity, or has-been celebrity, wants to walk around telling everyone they need to get Airpods? I don’t care.

I don’t care that one individual believes, well, any crackpot idea or conspiracy theory either. There was a guy in downtown Philly who walked around with a sign declaring that the alien invasion was nigh and we should save ourselves by … I don’t even remember what he thought would appease our future alien overlords. People generally ignored him or felt sorry for him. Sometimes gave him a hairy eyeball. And we all carried on.

When the crazy idea is picked up by more individuals? Nonsense is less objectionable when a lot of people believe it (i.e. there are people who read this doctor’s statements from the fifth source & think maybe it’s true).

When those who hold sway over a lot of other people start promoting disinformation? Some percentage of Trump’s 84.3 million followers, and some percentage of Madonna’s 2.6 million followers, take this seriously. They use the ‘information’ to justify mask refusal, heading out to parties, etc. Unless you’re completely off the grid, you’ll be sharing space with them at some point. That’s why I care.

Commerce Department Requests Section 230 Clarifications

Looks like the Commerce Department is actually following up on Trump’s social media EO with a petition to, among other things, specify that Section 230(c)(1) does not apply to service providers restricting availability of content or to suspend user’s access to provided services. PDF of the petition is available, and it’s listed on the FCC’s filing search as in the INBOX. I’m watching to see if there’s a proceeding where public comments can be submitted. If there is a public comment period, maybe GoFCCYourself could be redirected 🙂

Data Visualization – Renters at Risk of Eviction

Tonight, I saw a post about the percent of rental households facing eviction — a staggering statistic on its own, but percentages can hide large or small numbers. 22% or 55% of households facing eviction sounds awful, but how awful depends on how many households rent or own in the state. The government, however, publishes a lot of data about US households. Data profiles for 2018 are available, so I’m using the number of renters by state in 2018 to translate percentages into households.

This chart represents 18 million households facing eviction — this is housing units, not number of people. One household may be one person or it may be ten people.

Beyond the immediately obvious question of “where are all of these people going once they are evicted?, there is peripheral impact — a lot of rental units are financed. How are property owners paying when a quarter of their rental units vacant? Are their kids still going to school? The government insisted on rescuing “too big to fail” banks. Ten or twenty million homeless people across the country seems more dire. Yet our government cannot pass an unemployment extension in a timely fashion.

There’s a historical hypothesis that the relative stability of the past couple hundred years was achieved by maintaining a large middle class. People constantly plagued by poverty and starvation are open to suggested alternatives — what do you have to lose? But give 60% a little something — a decent place to live, enough food, transportation, a little extra money for “fun stuff” and you’ve got a populace invested in maintaining the status quo (however inequitable that may be). Mass unemployment and homelessness is the stuff of mass protest and revolution.