Month: July 2020
Linux Network Manager GUI
School Considerations
Oracle – Select Top
I discovered the “rownum” trick early in my usage of Oracle databases — especially useful for sampling data to see what’s in there, something like “select * from dataTable where rownum < 6” gets you the first five records. But that’s not suitable if you want to sort the records. In this particular case, I have a series of names. I want to find the highest number value in the series so I can name my object with the next sequential name.
Enter “fetch first” … this appears to be available since 12c (so older database installations may still require a more convoluted solution):
SELECT set_name from set_data WHERE set_name LIKE 'Something-With-A-Series-%' ORDER BY set_name DESC fetch first 1 row only;
Which returns the last name in the series.
PHP Sub-Second Sleep
I needed to add a sleep to a PHP process, but I didn’t want to waste a whole second on each cycle. That’s usleep:
<?php
date_default_timezone_set('America/New_York');
$t = microtime(true);
$micro = sprintf("%06d",($t - floor($t)) * 1000000);
$d = new DateTime( date('Y-m-d H:i:s.'.$micro, $t) );
print $d->format("Y-m-d H:i:s.u") . "\n";
usleep(100000);
$t = microtime(true);
$micro = sprintf("%06d",($t - floor($t)) * 1000000);
$d = new DateTime( date('Y-m-d H:i:s.'.$micro, $t) );
print $d->format("Y-m-d H:i:s.u") . "\n";
sleep(1);
$t = microtime(true);
$micro = sprintf("%06d",($t - floor($t)) * 1000000);
$d = new DateTime( date('Y-m-d H:i:s.'.$micro, $t) );
print $d->format("Y-m-d H:i:s.u") . "\n";
?>
Run the script, and you’ll see sub-second sleeps.
[tempuser@564240601ac2 /]# php testSleep.php
2020-07-09 14:06:20.641449
2020-07-09 14:06:20.741952
2020-07-09 14:06:21.742347
Marketing Fail
School’s Out For …
I want to know what schools are going to do in September/November after what they did in August proves to be foolishly optimistic (either ‘the virus will disappear’ or ‘one person will be able to ensure twenty six-year-old kids wear masks and stay 6 feet apart, plus we can have a janitor in each restroom sanitizing after each use’) and they’ve failed to use the intervening 4-5 months to develop a decent online teaching approach.
Ohio Public Health Warning Level
Ohio now has a per-county public health alert level rating that reminds me of the terror alert color-coded system we had after 9/11.
Of course there will be people in red or purple counties heading out to neighboring counties to shop/eat/socialize/party because those neighboring counties are only in orange so they don’t need to wear a mask there. I don’t get why I’ve got to get my car e-checked because my county borders Cuyahoga but we wouldn’t have to wear a mask for the same reason … but it’s a step in the right direction deeming masks mandatory *somewhere* based on *something*.
Oracle – Group By Having
I needed a query to find records where duplicate name values exist. I know how to group by and count, but the table has millions of records. I don’t want the 99% of the data where no duplication occurs. By using “having” in conjunction with “group by”, I am able to restrict the output to the groups that match my criterion.
select display_name, count(display_name) from circuit group by display_name having count(display_name) > 1;
My result set is the display name & occurrence count for that display name without all of the ‘good’ records where there’s a unique display name. (Yes, I know uniqueness could be enforced. The real scenario isn’t this straight-forward. There are times where the display name should be the same and I’ve got additional filters that drop out those cases).