Brad Gunn

Bottles of wine and poison

You have 1000 bottles of wine. One is poison. You have 10 mice. Each of the mice must drink at the same time. They can not be in sequence and you may not reuse mice that have drank. Thus, one shot to find the poison bottle. How do you distribute the wine such that you achieve this.



This was a fun problem! 


Failing to upgrade Ubuntu do-release-upgrade

Having this problem?





brad@ubuntu:~$ sudo do-release-upgrade -d Checking for a new Ubuntu release Traceback (most recent call last): File "/usr/bin/do-release-upgrade", line 145, in fetcher.run_options += ["--mode=%s" % options.mode, AttributeError: type object 'DistUpgradeFetcherCore' has no attribute 'run_options'



Ubuntu doesn't have the proper files that it needs. Just run:



sudo apt-get update && sudo apt-get upgrade --force-yes --yes



Then try again!


Threading in PHP

This should be interesting. I think I'll skip the turkey and play with this. http://pthreads.org/tutorials/start.html


LAMP Stack: Do You Really Need Gearman?

Thoughts; If you are using a framework that supports CLI execution, couldn't you write a 100 line command line that bootstraps the framework through ubuntu upstart ( and monitors it for crashes ) that just polls a table and performs row locks? MySQL can handle thousands of requests per second and it's hardly performing the heavy lifting, the job servers are. So you could have master/slave for redundancy.



Need scheduling ?



CREATE EVENT $randomized

   ON SCHEDULE AT CURRENT_TIMESTAMP + ( do math to get this: INTERVAL 1 HOUR )

   DO

     INSERT INTO queue values ( 'action', 'JSON/Serialized PARAMS' );



OPTIONALLY: repeat it every X



On the second your schedule cron comes due, you get a row in your queue and your job servers go to town. Already on a lamp stack? 100 lines and you've leveraged your stack to have a job server that can leverage everything you've written into your application without any external dependencies. Want visibility into your queue? Just write some code that reads these tables.



Ultimately, I like gearman, but I've gotten this to scale to 10,000 jobs a second in sandbox testing doing trivial tasks ( hell world ) with a mysql innodb table. It was really to demonstrate that MySQL could handle it. You leverage your existing stack without adding complexity by adding 2 more gearman servers ( HA ). More to come.


Hello World

Rather fitting for a first post. Consider me the alt. contributor & beta tester/user to this lovely website. More to come!