The fewer people to mistake memorization for thinking the better

Gravatar
Random Thoughts | Posted by apokalyptik

http://zenhabits.net/2010/02/ace-exams/

tsia

I’m sure we all know this feeling…

Gravatar
Funny Stuff, SRSLY, Software Development | Posted by apokalyptik

found at http://i.imgur.com/pdpIk.png via google reader explore functionality late one last night

Lunch

Gravatar
Random Thoughts | Posted by apokalyptik

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

Nikki In Training

Gravatar
Random Thoughts | Posted by apokalyptik

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!

This is actually pretty cool

Gravatar
Random Thoughts | Posted by apokalyptik

First person tetris… awesome… http://www.firstpersontetris.com/

Time based bloom filters

Gravatar
Business, PHP, Personal, Random Thoughts, Ruby (on or off) Rails, SRSLY, Software Development | Posted by apokalyptik

I find this concept fascinating and plan to investigate further down this road.

lockd, a memcached like locking daemon in php

Gravatar
Random Thoughts | Posted by apokalyptik

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 :D

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

  • g (string) — get an exclusive lock on the string
  • sg (string) — get a shared lock on the string
  • r (string) — release an exclusive lock
  • sr (string) — release a shared lock
  • i (string) — inspect an exclusive lock
  • si (string) — inspect a shared lock
  • q — query stats
  • q full — query stats and dump the exclusive and shared lock arrays

 

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.

This made me laugh :)

Gravatar
Random Thoughts | Posted by apokalyptik

The Adventures of Lil Cthulhu

Gravatar
Funny Stuff, Random Thoughts, WTF | Posted by apokalyptik

php debugging the really really hard way

Gravatar
Bash, Business, CLI, Linux, PHP, Random Thoughts, SRSLY, Software Development, WTF, Web Stuff | Posted by apokalyptik

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…