DojoConf 2011 Recap

Sep 28, 2011

The first ever DojoConf held in Washington DC was a huge success. I unfortunately missed about a quarter of the conference due to sleep. I dumped a lot of hours into my presentation about “The Art of Developing Nano Widgets” and it must have been worth it because everybody said they liked my talk.

So, what is a nano widget? It’s a lightweight widget that only has the code you use. If you use some tabs on your site, why would you need all that extra code for handling widget destruction, tabs on the bottom, IE6/7 support, child layouts, high contrast accessibility, and so on?

For this presentation, I created a new Dojo library called nano that currently contains a lightweight lightbox, tab container, and accordion container. You can find the code in my GitHub repo:

Here’s my slides. NOTE: slides require Chrome or Safari.

DojoConf had a great turnout and was very well organized thanks to the hard work of Chris Williams (@voodootikigod), Laura Williams (@lwilliams, and the remaining unsung heros. There was some good swag including a little Lego minifig branded with the Dojo logo thanks to LifeImage.

There were many good talks that I listened to. I really enjoyed Mike Wilcox’s presentation about Dojo and HTML5. In short, Dojo plays well with HTML5 forms, SVG, offline storage, and web sockets, but fails with things like semantic tags, audio, and video. There’s definitely room for improvement.

Luis Montes gave a great talk about HTML5 Game Development and Dojo (slides require use a modern browser). He talks about rendering graphics using a canvas element and physics with Box2D. Along the way, he’s describing how to leverage Dojo to make things such as object oriented game objects, server communication, and event handling.

Rebecca Murphey gave a really interesting talk about Building Large Apps using Dojo. She talks about they used Dojo to build Toura, a mobile content creation system. The big take away here is don’t build big apps, build several small apps and glue them together. Break up everything into components and use Dojo’s excellent event system to wire those components up.

On the last night of DojoConf, a group of us moved the after-after party back to hotel to close out what was a great conference!

Speaking at DojoConf 2011!

Sep 08, 2011

You heard right. I will be giving a talk at DojoConf 2011 coming up September 16-17 in Washington DC! I’ll be talking about “The Art of Developing Nano Widgets.” What is a nano widget? It’s simply a much smaller version of a fully featured Dijit counterpart. My talk will discuss the concept and implementation of nano-fying a handful of Dijit widgets.

DojoConf is the first real Dojo conference. There have been Dojo Developer Days in the past, but those are generally planning and decision oriented meetings. DojoConf is real content and a real schedule. There’s a great lineup of speakers and topics.

See you there!

Intro to PECL/mysqlnd_ms Presentation Slides

Apr 12, 2011

Last week I presented on the super cool PECL/mysqlnd_ms PHP extension at the Minnesota PHP User Group. In short, mysqlmd_ms will provide some transparency for PHP web applications to interact with master and slave MySQL database setups.

Here’s my slide deck:

There’s a couple things mysqlnd_ms needs to support before I can use it such as support for single master (i.e. local dev) environments and detection of “dead” MySQL servers so traffic isn’t passed to them over and over again.

I use a MacBook Pro for my day-to-day operations here at CB1, INC. I’m a huge believer that a development environment should mimic the production environment, so I find myself running a couple virtual machines in VMware Fusion.

The following guide is a reference for myself as well as possibly a helpful resource for setting up your own Linux development environment. Here’s an checklist of the tasks to perform and software to install:

Operating System

Start by installing Ubuntu 10.10 Desktop (or server). I’m not going to cover installing Ubuntu since there are already several other resources out there. Once Ubuntu is installed, open a Terminal:

user@ubuntu:~# sudo passwd root
[sudo] password for user: <type your password>
Enter new UNIX password: <type new root password>
Retype new UNIX password: <type new root password again>
passwd: password updated successfully

user@ubuntu:~# sudo apt-get update
user@ubuntu:~# sudo apt-get upgrade

user@ubuntu:~# mkdir ~/src

New File Permissions

user@ubuntu:~# sudo pico /etc/profile

Change 022 to 002. This setting controls the default permissions when a new file or directory is created. This is mostly useful when managing files over Samba.

Network IP Addresses

Optionally, you may want to assign a static IP address. I set up one IP address for Apache and another for nginx.

user@ubuntu:~# sudo pico /etc/network/interfaces

The following is a reference for adding two static IPs. Change the IPs to meet your needs.

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

auto eth0:1
iface eth0:1 inet static
user@ubuntu:~# sudo /etc/init.d/networking restart


Here’s a bunch of packages that will set up compilers, version control, Java, MySQL, Apache, PHP, Memcache, Gearman, Samba, and more.

user@ubuntu:~# sudo apt-get install build-essential autotools-dev autoconf \
 autoconf2.13 openssh-server ethtool traceroute openjdk-6-jdk \
 mysql-server-5.1 bzr subversion subversion-tools ntp ntpdate \
 libpcre3-dev libevent-dev automake bison libtool scons  g++ \
 ncurses-dev libreadline-dev libz-dev libssl-dev  libcurl4-openssl-dev \
 ruby rubygems libzip-ruby1.8 libzip-ruby1.9.1 python-dev ruby-dev \
 libdbus-glib-1-dev uuid-dev libpam0g libpam0g-dev gperf samba valgrind \
 libxml2-dev libfreetype6-dev curl libcurl4-openssl-dev \
 libjpeg62-dev libpng12-dev sqlite3 libsqlite3-dev git-core \
 postgresql postgis gearman libgearman-dev php5 \
 libapache2-mod-php5 php5-dev memcached php5-memcached \
 php5-curl php5-gd php5-mysql php5-pgsql php-apc \
 php5-xdebug php5-fpm libapache2-mod-fastcgi


During the package install above, MySQL will prompt you for the root password.

After the packages are installed, we need to allow remote MySQL connections.

user@ubuntu:~# sudo pico /etc/mysql/my.cnf

Comment out the bind-address line.

# bind-address          =


Next, you may optionally increase the connection keep alive interval for remote ssh connections. Timeouts aren’t really an issue for SSH’ing into a local VM, but really helps for remote installs.

user@ubuntu:~# sudo echo "ClientAliveInterval 60" >> /etc/ssh/sshd_config


Samba allows me to drag and drop files between my Mac and Linux VM. I personally do not enable/install Samba on production servers.

user@ubuntu:~# sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
user@ubuntu:~# sudo pico /etc/samba/smb.conf

You can add a share such as the following:

        force user = <your username>
        writeable = yes
        create mode = 644
        path = /home/<your username>
        directory mode = 755
        force group = <your username>

Then create yourself a Samba user:

user@ubuntu:~# sudo smbpasswd -a <your username>

Apache 2

Apache is mostly configured out of the box, but I like to enable rewrite and SSL so I can test production features.

user@ubuntu:~# sudo a2enmod rewrite
user@ubuntu:~# sudo a2enmod ssl

Since I’m going to run Apache and nginx, I’m going bind Apache to eth0.

user@ubuntu:~# sudo pico /etc/apache2/ports.conf

<IfModule mod_ssl.c>

Now we need to add eth0‘s IP to the default host:

user@ubuntu:~# sudo pico /etc/apache2/sites-enabled/000-default
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

Restart Apache for the changes to take effect.

user@ubuntu:~# sudo apache2ctl restart


By default, Gearman uses memory to store pending jobs in the queue, but I prefer to use MySQL for persistent storage. To do this, first create the queue database and table:

user@ubuntu:~# mysqladmin -uroot -p123123 create gearman
user@ubuntu:~# mysql -uroot -p123123 -e "CREATE TABLE gearman.gearman_queue (
  unique_key VARCHAR(64) NOT NULL,
  function_name VARCHAR(255) NULL,
  priority INT NULL,
  PRIMARY KEY (unique_key)
) ENGINE = InnoDB;"

Next update the init script to tell Gearman to use the database:

user@ubuntu:~# sudo mv /etc/default/gearman-job-server /etc/default/gearman-job-server.bak
user@ubuntu:~# sudo echo "PARAMS=\"-q libdrizzle --libdrizzle-host=" \
   "--libdrizzle-user=root --libdrizzle-password=123123 --libdrizzle-db=gearman" \
   "--libdrizzle-table=gearman_queue --libdrizzle-mysql\"" > /etc/default/gearman-job-server
user@ubuntu:~# sudo /etc/init.d/gearman-job-server restart

Gearman PHP Extension

We need to download and install the Gearman PHP extension if we want to write PHP workers or post jobs to the queue.

user@ubuntu:~# cd ~/src
user@ubuntu:~/src# wget
user@ubuntu:~/src# tar xzf gearman-0.7.0.tgz
user@ubuntu:~/src# rm gearman-0.7.0.tgz package.xml
user@ubuntu:~/src# cd gearman-0.7.0
user@ubuntu:~/src# phpize
user@ubuntu:~/src# ./configure
user@ubuntu:~/src# make
user@ubuntu:~/src# sudo make install

Next, add the config file to load the Gearman PHP extension:

user@ubuntu:~# sudo echo "" >> /etc/php5/conf.d/gearman.ini

memcached PHP Extension

Since we have memcached and the memcached PHP extension install, let’s use it for storing session data:

user@ubuntu:~/src# sudo echo "session.save_handler = memcached
session.save_path = \"\"" >> /etc/php5/conf.d/memcached.ini


nginx is web server that is really fast. I use nginx as my primary development web server unless I’m running a web app that only works with Apache. You can choose to install nginx from package, but I like to live life on the bleeding edge, so I’ll be building nginx from source. To install nginx, we need to download the source, compile it, install it, and configure it.

user@ubuntu:~# cd ~/src
user@ubuntu:~/src# wget
user@ubuntu:~/src# tar xzf nginx-0.8.52.tar.gz
user@ubuntu:~/src# rm nginx-0.8.52.tar.gz
user@ubuntu:~/src# cd nginx-0.8.52
user@ubuntu:~/src# mkdir /var/lib/nginx
user@ubuntu:~/src# ./configure \
    --sbin-path=/usr/sbin \
    --conf-path=/etc/nginx/nginx.conf \
    --error-log-path=/var/log/nginx/error.log \
    --pid-path=/var/run/ \
    --lock-path=/var/lock/nginx.lock \
    --http-log-path=/var/log/nginx/access.log \
    --http-client-body-temp-path=/var/lib/nginx/body \
    --http-proxy-temp-path=/var/lib/nginx/proxy \
    --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
    --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
    --http-scgi-temp-path=/var/lib/nginx/scgi \
user@ubuntu:~/src# make
user@ubuntu:~/src# sudo make install

user@ubuntu:~# sudo pico /etc/init.d/nginx

Here’s the init script that will start nginx for us:

#! /bin/sh
test -x $DAEMON || exit 0
case "$1" in
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /var/run/$ --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /var/run/$ --exec $DAEMON
        echo "$NAME."
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile /var/run/$ --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --pidfile /var/run/$ --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        echo -n "Reloading $DESC configuration: "
        start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$ --exec $DAEMON
        echo "$NAME."
        echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2
        exit 1
exit 0

Now we need to make the init script executable and enable it:

user@ubuntu:~# sudo chmod +x /etc/init.d/nginx
user@ubuntu:~# sudo update-rc.d nginx defaults

user@ubuntu:~# sudo pico /etc/nginx/nginx.conf

Here’s a starter nginx.conf with some basic settings:

user  www-data www-data;
worker_processes  2;

events {
    worker_connections  1024;

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile                on;
    tcp_nodelay             on;
    tcp_nopush              on;
    keepalive_timeout       65;
    server_name_in_redirect off;
    server_tokens           off;

    add_header Strict-Transport-Security max-age=1800;
    add_header X-Frame-Options deny;

    gzip            on;
    gzip_buffers    16 8k;
    gzip_comp_level 9;
    gzip_types      text/plain text/xml application/x-javascript text/css;

    include /etc/nginx/sites/*;
user@ubuntu:~# sudo mkdir /etc/nginx/sites
user@ubuntu:~# sudo pico /etc/nginx/sites/default

Now we need to set up a default host that supports PHP (via PHP-FPM, PHP’s FastCGI Process Manager) and we want the default host to use the eth0:1 IP address:

server {
    listen default;
    server_name  _;
    root   /var/www;
    index  index.php;
    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php?q=$1 last;
    location ~ \.php$ {
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
        include        fastcgi_params;
    location ~* (\.(htaccess|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ {
        deny all;

After the config files are good to go, start nginx:

user@ubuntu:~# sudo /etc/init.d/nginx start

Service Names

I also like to add service names so I can see what ports are in use when I run netstat. I added drizzle and Cassandra for fun despite this post not including them.

user@ubuntu:~# sudo cp /etc/services /etc/services.bak
user@ubuntu:~# su
root@ubuntu:~# echo "drizzle     4427/tcp
drizzle     4427/udp
memcached   11211/tcp
memcached   11211/udp
gearmand    4730/tcp
gearmand    4730/udp
fastcgi     9000/tcp
cassandra   9160/tcp" >> /etc/services
root@ubuntu:~# exit

Android SDK

The Android SDK is unfortunately not in package, so you’ll need to download it from the Android Developer site:

user@ubuntu:~# wget
user@ubuntu:~# tar xzf android-sdk_r07-linux_x86.tgz
user@ubuntu:~# rm android-sdk_r07-linux_x86.tgz
user@ubuntu:~# sudo mv android-sdk-linux_x86 /usr/local
user@ubuntu:~# sudo find /usr/local/android-sdk-linux_x86 -type d -exec chmod 777 {} \;

You’ll need to add the Android SDK path near the top of your ~/.bash_profile or ~/.bashrc:

export PATH=${PATH}:/usr/local/android-sdk-linux_x86/tools

To manage your Android SDK packages and virtual devices, you’ll need to run the android app:

user@ubuntu:~# android

First go to Available Packages and download version 1.6 and 2.2 Android SDK packages. You can also choose to download the documentation, samples, and Google APIs.

Downloading the package may take several minutes. You don’t have to create a virtual device right now if you are planning on installing Appcelerator’s Titanium platform. You can exit the Android app when you’re done.

Desktop Apps

If you’re running Ubuntu Desktop, there are a couple handy apps I install. The first is Google Chrome and can be directly downloaded from the Google Chrome download page.

I find KCachegrind and GHex to be useful:

user@ubuntu:~# sudo apt-get install kcachegrind ghex

Appcelerator Titanium

Titanium is an awesome platform for developing desktop applications for Linux, Mac OS X, and Windows as well as mobile apps for iPhone and Android. We use Titanium Developer to create Titanium projects. Begin by downloading the 64-bit version of Titanium:

user@ubuntu:~# wget -O titanium.tgz

There’s also a 32-bit version available at

Next we unpack Titanium Developer and move it to a safe place:

user@ubuntu:~# tar xzf titanium.tgz
user@ubuntu:~# rm titanium.tgz

Next you need to run the installer by double-clicking the Titanium Developer executable. Run the executable and then click the Install button. You can try installing to /opt/titanium, but you might need root privileges.

Next, there are a few issues with outdated libraries, so we simply delete them:

user@ubuntu:~# rm ~/.titanium/runtime/linux/1.0.0/libgobject-2.0.*
user@ubuntu:~# rm ~/.titanium/runtime/linux/1.0.0/libglib-2.0.*
user@ubuntu:~# rm ~/.titanium/runtime/linux/1.0.0/libgio-2.0.*
user@ubuntu:~# rm ~/.titanium/runtime/linux/1.0.0/libgthread-2.0.*

Titanium Developer also complains if /bin/java doesn’t exist, so create a quick link:

user@ubuntu:~# sudo ln -s /usr/bin/java /bin/java

Relaunch Titanium Developer and enter your login credentials. If you don’t have a login, you can get a free account.

After signing in, you may notice there are some updates available in the upper right corner of the window. Click in the box and the updates will be downloaded and installed.

Optionally you can create a launcher icon for your GNOME panel. Don’t forget to escape spaces in the command with a backslash!

Finishing Touches

Lastly, I like to re-arrange my desktop to maximize my coding real estate.


That should get you up and running with a neato dev environment. If you need to run SSL, I wrote a post on Creating Self-Signed Certs on Apache 2.2 and Virtual Hosts and Wildcard SSL Certificates with Apache 2.2.

If you find any typos or additions, please feel free to sound off in the comments!

If you have a MacBook Pro with several gigabytes of RAM, you may have noticed that Mac OS X will lock up when you try to wake the laptop up. This can be very frustrating and requires you to hold the power button in for 5 seconds and turning it back on.

I run 2 or 3 VMware Fusion virtual machines at the same time and that eats up a ton of RAM, but it’s OK since my laptop has 8GB of memory. My machine would lock up when I tried to wake it up. I found that it would sometimes be OK leaving 1 virtual machine running, but if I left 2 running, it would almost always lock up.

So, I did some research and discovered the problem has to do with Mac OS X’s power management, specifically the hibernatemode. The value is a bitfield that has the following options:

  • 0 (0000) Disables SafeSleep. Memory state is maintained until battery power is gone in which case the computer turns off completely.
  • 1 (0001) Enables hibernation, writes memory contents to hibernation image, and immediately goes to sleep.
  • 3 (0011) Maintains memory state while sleeping, but when the battery power is nearly gone, it will write the contents of the memory to hibernation image.

On laptops, the default value is 3. On desktops, the default is 0.

To fix the problem, you simply need to set the hibernatemode to 0. From a Mac OS X terminal, run the following:

sudo pmset -a hibernatemode 0

Then reboot your laptop and enjoy lock-free waking up!

At this point, hibernation is disabled and that means you can delete the hibernation file and free up a couple gigs of disk space!

sudo rm -f /var/vm/sleepimage

One side note, Microsoft Windows actually disables hibernating on computers with 4GB or more of RAM. They claim that it took longer to restore the memory state from disk than to just do a normal boot. I disagree since it takes a long time to spin up all your apps, virtual machines, and start being productive. I wonder if they discovered some technical issue that is what is causing the issues on Macs.

Tonight I gave a talk about Cassandra at the Minnesota PHP User Group. I would hope that everyone that came out learned a little something. I have to admit the talk was a bit unorganized, but hey, I love to talk. It also didn’t help that there was major construction going on at the meeting venue that made it hard for people to hear me.

After rambling for an hour and a half, I finally ran out of Cassandra-related stuff to talk about. Since some people were interested in some new features of PHP 5.3, I showed off my MVC framework I’ve been working on called Elevate. In Elevate’s code, I use some of PHP 5.3’s new features such as closures, namespaces, and the ternary operator (?:). I also showed Elevate’s super cool Gearman worker daemon that I used for sending e-mails.

This Thursday, May 6th, at 6pm I’ll be giving a talk about Cassandra at the Minnesota PHP User Group.


I’ll be covering Cassandra’s architecture and how it scales to handle tons of data and still be fast and fault tolerant. I’ll also cover Cassandra’s API and data modeling, specifically with PHP.

The user group will meet at Nerdery Interactive Labs (9555 James Ave S, Suite 245, Bloomington, MN 55431). It will surely be packed with tons of awesome, so be sure to RSVP!

This year, Portland gets not one, but two open source conferences: OSCON and Open Source Bridge (OSB). I attended OSCON in both 2008 and 2009, but this year the cycle may break. Instead I’ve opted to go to OSB in hopes that it will be more technical and less commercial. Not to mention, OSB is 20% the cost of OSCON.

The cutoff date for this years OSB proposals was just a few days ago and there are about 400 submissions. I considered submitting a talk about Dojo, but due to time constraints, I had to pass this year. Regardless, there are several talks that are pretty interesting and I hope they get selected. The topics that I’m most interested in are:

  • Distributed databases and data modeling
  • Cloud deployment and management
  • PHP tricks
  • Drizzle
  • Websockets
  • Concurrency and threading
  • Geolocation
  • Scalability and performance

A little disappointed there weren’t more JavaScript or C/C++ talks. For a complete list of sessions that I’d like to attend, check out my favorites sessions.

April 1st, 2010 is the last day to get the early bird discount for $225, otherwise it goes up to a whopping $300. You can register on their site:


The first dojo.connect online conference is coming up this week February 10-12, 2010. I’ll be giving a talk about Debugging Dojo Applications. I’ll be covering the following:

  • Common mistakes and how to avoid them
  • Web browser debug tools
  • Built-in Dojo debugging tools
  • Methods for finding and fixing syntax issues or malformed data
  • Writing tests to trap specific bugs

There is still room left, so head over to and sign up today!