http://zenhabits.net/2010/02/ace-exams/
tsia
The random things that spew forth from my brain…
I make a fruit salad kind of thing almost every single day for lunch. And for some reason, today, I thought I would record the process. This is how I make a fruit salad… How do you do it?
for the record this is not an exciting or cool video… its just me… cutting up fruit… silently
I just want to share with everyone how proud I am of my Nikki. She’s been training to do a half marathon for charity (and to get into shape.) She’s just been stellar about it. She’s walking tons, and lost a bucketload of weight. I’m sure that she would love it if anyone wanted to drop by and give her some words of encouragement on her blog where she’s keeping a log of her Journey. Thats my wife!
First person tetris… awesome… http://www.firstpersontetris.com/
I find this concept fascinating and plan to investigate further down this road.
You might have seen my last post about this code (here) if you are one of my 2.3 loyal readers
. It wasnt nearly so complete or robust then (segfaulting? come on! right?)
The segfaulting was caused by stupidly using $this->function() from inside of $this->function() for recursion, overloading the stack. Note to self: don’t be lazy about recursion
If you’re interested in the project I have it setup over here: http://code.svn.wordpress.org/lockd/ so please feel free to try it out.
What is it? It’s a network based locking mechanism. You can connect to it over TCPIP and get either exclusive or shared locks for as many arbitrary strings as you like. Shared locks have the added benefit of being counted. You can query to see if a string is locked (and how many times for shared locks.) You can also release locks.
All of this is useful, but… The nice thing about lockd, though, is that if your client disconnects (say the process which had locked a string quit unexpectedly) lockd will automatically orphan those locks for you. So you have no need to try and cleanup and guess the lock state of a failed process. And since this runs as a network daemon you can have as many of them as you like. You can use them for local (locks on the same box) or distributed (locks on the same resource from many boxes.) It also comes with built in stats which you could hook up to munin, or nagios, via netcat without too much trouble.
The protocol is also extremely simple
Thats it. “(int) (string)” is returned for these commands. where (int) is for programmatic use, and (string) is for human consumption.
We use this with the Jobs system (also available as an OSS project) for WordPress.com, Intensedebate, Gravatar, and more, and is currently handling nearly a million operations per day… per server…
This is Itch-Scratch-Ware at its finest.
If you’re ever in a situation where something is only happening intermittently, and only on a live server, and only while it’s under load… Lets say its not generating any error_log or stderr output, and you cant run it manually to reproduce… (we’ve all been in this situation) How do you get any debugging output at all?
Step 1: add this to the top of your entry point php file
if ( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' ) { error_log( ' :: ' . getmypid() ); sleep( 10 ); }
Step 2: use curl on the localhost to make the request
Step 3: (this assumes your error log is /tmp/php-error-output) run the following command in a second (root) terminal window
strace -p $(tail -n 1000 /tmp/php-error-output | grep ' :: ' | tail -n 1 | sed -r s/'^.+ :: '//g) -s 10240 2>&1
Good luck…