Category: Technology

HTML – Multiple Values on Select Option

I needed to pass multiple values with a select option. It’s easily accomplished by setting the value to a JSON string

while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
	echo "<option value= " . json_encode($row) . ">" . $row['STRTYPENAME'] . "</option>\n";
}

And using JSON.parse to pull out the key of the value you need:

jQuery("#selectDivSetType").change(function () {     
    var strTemplateObject = $('#selectDivSetType').val();
    var jsonTemplateObject = JSON.parse( strTemplateObject );
    var strTemplateURI = './templates/' + jsonTemplateObject.STRTEMPLATENAME;
    $('#templateURI').attr("href", strTemplateURI); 
});

jQuery – Changing href When Drop-down Selection Changes

I needed to provide a different template depending on the type of activity selected in a drop-down menu. The following jQuery code gets the template name from the drop-down value and updates the href target.

jQuery("#selectDivSetType").change(function () {     
    var strTemplateName = $('#selectDivSetType').val();
    var strTemplateURI = './templates/' + strTemplateName;
    $('#templateURI').attr("href", strTemplateURI); 
});

Exporting Microsoft Stream Transcript — Prettier Output and Error Handling

Updated script available at https://www.rushworth.us/lisa/?p=6854 — and, since copy/paste doesn’t seem to work for everyone, the script is also available as a text file.

I had posted a one-liner to grab the text content of the Microsoft Stream transcript — there’s a good bit of cleanup required to make something professional looking, but I’ve been lazy about it & leave formatting up to the recipient. The one-liner approach fails when it doesn’t encounter a text element where it expects to find one. A more robust export approach creates a Node List containing all of the transcript-line classed elements, then iterates through that list and when the node has a textContent attribute appends that content to a running string value. Printing the running string value produces output that needs minimal reformatting.

Code:

var objTranscriptLines = window.document.querySelectorAll('.transcript-line');
var strRunningText = null;
for(var i = 0; i < objTranscriptLines.length; i++){
    if( objTranscriptLines[i].textContent ){
        var strLineText = objTranscriptLines[i].textContent;
        strRunningText = strRunningText + "\n" + strLineText.replace("Discard   Save","");
    }
}
console.log(strRunningText);

Results:

You *could* strip off the timestamps as well — instead of strLineText.replace(“Discard Save”,””) use (strLineText.replace(“Discard    Save”,””)).substr(8)

Scratch: Changing Variable In Operator

When I needed to change a variable within an operator block, I’d been removing the variable block and adding the right one. Unlike the “change <variable> …” and “set <variable>…” blocks, the little variable name bubbles do not have a drop-down selector. Today, Anya and I were working on our Chicken Keepers games and she right-clicked the little bubble to select a different variable. Totally didn’t realize you could do that.

Scratch – Touching Clones

While you can detect when a clone is touching a main sprite, there’s no way to detect if something is touching a clone. The workaround is to use broadcast messages to trigger events.

1. In the clone, create an “if touching” block to detect when it is being touched by the sprite

2. Within the if-touching block, send a broadcast message (under the “Events” blocks)

3. On the other sprite, create a block triggered by the “I receive” event for the code you want to run when this sprite touches the clone of another sprite.

4. Now a sprite executes the desired code when it is touching the clone of another sprite.

 

Git — Show Dates For Branches

We wanted to see all of the branches in a repository with the dates of the latest commit:

git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:rfc-local) %(refname:short)'

This outputs the full date/time (you can use any of the git log date formats [relative|local|default|iso|rfc|short|raw] after committerdate; short for the date without time)

 

Decompiling Jython Class Files

Looks like Jython that is compiled into a class file can be decompiled just like a Java class (I use jd-cmd which is both simple and open source). But … you don’t get back Python. In a disaster recovery scenario, you get back something and could reconstruct your Python code from the Java-looking stuff you get back.

I don’t normally type the entire command — a quick function in your .bashrc gives you a command alias that can be used instead.

The Dog Ate My Homework

 
‘The police department acknowledged errors in the report that it said was the result of the reporting program creating a paper file.
 
“Inaccuracies in the report are unacceptable to us, and we are taking immediate steps to correct the report and to ensure the accuracy of incident reports going forward,” the statement said.’
 
Seriously? “Software problem” has become the new ‘dog ate my homework’. Do they actually expect someone to believe the software somehow turned their verbose and well-documented description of what actually happened to “PIU investigation”?! Leaving that element aside …
 
I’ve done software development for some 25 years. From a technical standpoint, incorrect data mapping happens — worked on a bank project once where they had bought a smaller company and mis-mapped previous and current address fields (+ instituted an annual fee — notice of which was sent to your previous address. Along with the first bill on a card you hadn’t used in three years, the next month’s bill with late fee and interest, the next next month’s bill … you get the idea. It was an ugly cleanup process full of angry people who generally didn’t even realize they *had* that card anymore, never mind wanting to pay 30$ a year to have said card).
 
But here’s the thing — you don’t randomly map “forced intrusion == true” to an unchecked box or find a non-null list of injuries and write “none” as a one-off. If they had one data inconsistency and wanted to claim a software bug? Suspect but technically possible — some specific data condition caused a problem generating a paper report. But *this* many errors in the reporting program impact *just* this one report? In the credit card company case, the *only* people who had their current address listed as their mailing address had never moved. 100% of the people with a previous address had that address recorded as their current address. I’ve encountered companies that had problems in specific conditions — everyone in Alaska had a bad address because someone had mapped “AR” to “Alaska” on the input form drop-down.
 
If their software had data mapped wrong in the paper file generation process, it would be generating bad paper files rather regularly. And, honestly, if the department wants to stick with this story … they need to put major time into validating all of the *other* paper files that the software has generated.