If you live and work by your phone
And you have indoor pets
Do not, under any circumstances, place your phone near and above a large glass of water.
We now return you to your regularly scheduled internet
If you live and work by your phone
And you have indoor pets
Do not, under any circumstances, place your phone near and above a large glass of water.
We now return you to your regularly scheduled internet
So now back off to the vet to pick up the dog who’s gonna spend most of the next few weeks being MISERABLE because he’s gonna have to be crated a a LOT, wont be able to play with the other dogs at all for a while, and will have to wear a satellite-dish-collar. On the plus side he’ll have a drain installed in his ear and he’ll be leaking gross fluids form his head for a while. I guess theres ALWAYS a silver lining, insn’t there?!
Well… everything that could go wrong this weekend (outside work) has gone wrong.
My replay tv is dying
My wifes laptop is dying
I have one dog getting out of surgery right now because of a hematoma
I have one cat with ringworm
One cat got the crap beat up out of her in a fight
I had my tire punctured so badly it needs replacing (this was on the way to the vet yesterday night when we noticed the swelling in buddy’s ear (the hematoma))
The dogs chewed a hose
One dog ate my wifes flipflops while we were away and puked pieces of it up all over the house
We have to go back to Fremont sometime this week to return the old cable receiver and modem or get sent to collections
Oh, and the IRS sent us a letter about a form missing from my tax return (I used TaxCut to avoid exactly this kind of crap!)
On the plus side… We’re alive 🙂
Actually it’s an eye specialist. My poor Bella’s eye (which has a detached lens and possibly glochoma (sp?)) has really been acting up the last several days. Wish her (and my wallet) luck!
Well at the zoo we lost a pair of glasses, so off to lensecrafters… no eye exam in 3 years… so eye exam… 2 hors for glasses… and WHAM a day thats supposed to end at 4:00pm ends at 9:00pm… sigh… 🙂 we now return you to your regularly scheduled blogging.
I’m putting this here for documentation purposes… Because getting it right was a very frustrating ordeal (I’d never had to match both positively and negatively in the same regex before)
/^(?(?!.+\.php)^.*(\.jpg|\.jpeg|\.gif|\.ico|\.png)|^$)/s
what this is, essentially, saying is “true if the string doesnt match ^.+\.php and the string matches ^.*(\.jpg|\.jpeg|\.gif|\.ico|\.png)” The last bit: “|^$” never returns true in my case,because we’re matching on URI’s which are always at least one character long ( “/” )
Occam’s razor strikes again!
Tonight we ran into an interesting problem. A web service – with a very simple time-elapsed check – started reporting negatives… Racking our brain, pouring over the code, produced nothing. It was as if the clock were jumping around randomly! No! On a whim Barry checked it and the clock was, indeed, jumping around…
# while [ 1 ]; do date; sleep 1; done Wed May 30 04:37:52 UTC 2007 Wed May 30 04:37:53 UTC 2007 Wed May 30 04:37:54 UTC 2007 Wed May 30 04:37:55 UTC 2007 Wed May 30 04:37:56 UTC 2007 Wed May 30 04:37:57 UTC 2007 Wed May 30 04:37:58 UTC 2007 Wed May 30 04:37:59 UTC 2007 Wed May 30 04:38:00 UTC 2007 Wed May 30 04:38:01 UTC 2007 Wed May 30 04:38:02 UTC 2007 Wed May 30 04:38:19 UTC 2007 Wed May 30 04:38:21 UTC 2007 Wed May 30 04:38:22 UTC 2007 Wed May 30 04:38:23 UTC 2007 Wed May 30 04:38:24 UTC 2007 Wed May 30 04:38:08 UTC 2007 Wed May 30 04:38:09 UTC 2007 Wed May 30 04:38:10 UTC 2007 Wed May 30 04:38:28 UTC 2007 Wed May 30 04:38:12 UTC 2007 Wed May 30 04:38:30 UTC 2007 Wed May 30 04:38:31 UTC 2007 Wed May 30 04:38:32 UTC 2007 Wed May 30 04:38:33 UTC 2007 Wed May 30 04:38:34 UTC 2007 Wed May 30 04:38:35 UTC 2007 Wed May 30 04:38:19 UTC 2007 Wed May 30 04:38:20 UTC 2007 Wed May 30 04:38:21 UTC 2007 Wed May 30 04:38:22 UTC 2007 Wed May 30 04:38:40 UTC 2007 Wed May 30 04:38:41 UTC 2007 Wed May 30 04:38:42 UTC 2007 Wed May 30 04:38:43 UTC 2007 Wed May 30 04:38:44 UTC 2007
Most times when people write command line scripts they just let the output flow down the screen as a status indicator, or just figure “it’s done when it’s done” But sometimes it would be nice to have a simple clean status indicator, allowing you to monitor progress and gauge time-to-completion. This is actually very easy to accomplish. Simply use
instead of
in your output. Obviously the example below is very simplified, and this can be applied in a much more sophisticated fashion. But it works.
$row_count = get_total_rows_for_processing(); $limit=10000; echo "\r\n[ 0%]"; for ( $i=0; $i < = $row_count; $i = $i + $limit ) { $query="SELECT * FROM table LIMIT {$limit} OFFSET {$i}"; // do whatever $pct = round((($i+$offset)/$row_count)*100); if ( $pct < 10 ) { echo "\r[ $pct%]"; } else { if ( $pct < 100 ) { echo "\r[ $pct%]"; } else { echo "\r[$pct%]"; } } } echo "\r[100%]\r\n";
Sometimes it’s desirable to have a chain of commands backgrounded so that a multi-step process can be run in parallel. And often times its not desirable to have yet another script made to do a simple task that doesn’t warrant the added complexity. An example of this would be running backups in parallel. The script sniplet below would allow up to 4 simultaneous tar backups to run at once — recording the start and stop times of each individually — and then wait for all the tar processes to finish before exiting
max_tar_count=4 for i in 1 3 5 7 2 4 6 8 do cur_tar_count=$(ps wauxxx | grep -v grep | grep tar | wc -l) if [ $cur_tar_count -ge $max_tar_count ] then while [ $cur_tar_count -ge $max_tar_count ] do sleep 60 cur_tar_count=$(ps wauxxx | grep -v grep | grep tar | wc -l) done fi ( echo date > /backups/$i.start && tar /backups/$i.tar /data/$i && echo date > /backups/$i.stop )& done cur_tar_count=$(ps wauxxx | grep -v grep | grep tar | wc -l) while [ $cur_tar_count -gt 0 ] do sleep 60 cur_tar_count=$(ps wauxxx | grep -v grep | grep tar | wc -l) done
The real magick above is highlighted in red. You DO want that last loop in there to make the script wait until all the backups are really done before exiting.
I’m the kinda guy who owns up to my mistakes. I also strive to be the kinda guy who learns from them. So I figured I would pass this on as some good advice from a guy who’s “screwed that pooch”
There was a project on which I was working, and that project sent me e-mail messages with possible problem alerts. All was going well, and at some point I turned off those alerts. I don’t remember when. And I don’t remember why. Which means I was probably “Cleaning up” the code. It was, after all, running well (I guess.) But along comes a bug introduced with new functionality (ironically a from somewhere WAAAAAAY up the process chain from my project). And WHAM, errors up the wazzoo. But no e-mails. Oops. Needless to say the cleanup process was long and tedious… especially for something that was avoidable.
I’ve since put the alerting code back into the application, and have my happy little helpers in place fixing the last of the resulting issues.
The lesson to be taken from this is that you’re only ever done debugging for now. Because tomorrow that code, thats working perfectly now, wont be working perfectly anymore. And that the sources for entropy are, indeed, endless.