just thought about changing my twitter handle, but all the straight-forward variations of my name were taken by users with no tweets and 3-5 followers! lame.  guess i’ll stick with rfan622.

gave a presentation at the fbFund

so I gave a talk early Wednesday morning.  the talk was supposed to be about ‘rapid prototype’ but realized i had much more to share when talking about running a start-up as a whole.  so i kinda morph’ed the topic to be more about ‘rapid prototyping’ a startup rather than just a product.  in the end, it really was more a ‘tips and tricks’ for apply the lean startup methodology.

in any case, here are the slides that i used at the presentation.  I think there is some audio associated with this that I’ll post up when I get it.

Rapid Prototyping A Startup View more presentations from Robert Fan.

Continuous Integration: Selenium + Firefox + Flash

Another continuous integration how-to to put into the Web.  This one is specifically about getting Selenium working in Ubuntu to test Firefox and Flash.

Download and Unpack Selenium RC.  Make sure you get the latest version since it has udpated support for firefox3.

You put the Selenium RC files wherever you want, I put it in ‘/opt/local’

Now install a couple of things:

apt-get install firefox-3.0
apt-get install flashplugin-nonfree
apt-get install xvfb

To do a quick test you can kick-off xvfb to create a fake virtual framebuffer using:

/usr/bin/Xvfb :99 &

If you type ‘firefox’ now you should see it prompt to the next line (without any errors) meaning that it was successfully loaded.  Hit CTRL-C to kill this instance of Firefox.

With Xvfb still running, kick-off the selenium server:

java -jar <PATH TO YOUR SELENIUM SERVER>/selenium-server.jar

Run your FlashSelenium tests and they should go green!  No need to do anything specific with the browser type.  The 1.0 version of selenium can properly find Firefox 3.0 in Ubuntu.

Now if you are like me, you’ll probably want these two guys to be loaded upon startup.

Here’s the init.d for Xvfb:

#!/bin/bash

if [ -z "$1" ]; then
echo "`basename $0` {start|stop}"
exit
fi

case "$1" in
start)
/usr/bin/Xvfb :99 &
;;

stop)
killall Xvfb
;;
esac

Make sure you give the script executable permissions with:

chmod 755 xvfb

Here’s the init.d for Selenium:

#!/bin/bash

case "${1:-''}" in
        'start')
                if test -f /tmp/selenium.pid
                then
                        echo "Selenium is already running."
                else
                        java -jar /opt/local/selenium-remote-control-1.0.1/selenium-server-1.0.1/selenium-server.jar > /tmp/selenium.log & echo $! > /tmp/selenium.pid
                        echo "Starting Selenium..."

                        error=$?
                        if test $error -gt 0
                        then
                                echo "${bon}Error $error! Couldn't start Selenium!${boff}"
                        fi
                fi
        ;;
        'stop')
                if test -f /tmp/selenium.pid
                then
                        echo "Stopping Selenium..."
                        PID=`cat /tmp/selenium.pid`
                        kill -3 $PID
                        if kill -9 $PID ;
                                then
                                        sleep 2
                                        test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid
                                else
                                        echo "Selenium could not be stopped..."
                                fi
                else
                        echo "Selenium is not running."
                fi
                ;;
        'restart')
                if test -f /tmp/selenium.pid
                then
                        kill -HUP `cat /tmp/selenium.pid`
                        test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid
                        sleep 1
                        java -jar /opt/local/selenium-remote-control-1.0.1/selenium-server-1.0.1/selenium-server.jar > /tmp/selenium.log & echo $! > /tmp/selenium.pid
                        echo "Reload Selenium..."
                else
                        echo "Selenium isn't running..."
                fi
                ;;
        *)      # no parameter specified
                echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
                exit 1
        ;;
esac

Again, make this executable:

chmod 755 selenium

Before you add this to your startup scripts, you should probably test them out. If you’ve been following these write-up to a tee, you’ll have to kill both Selenium and Xvfb.  You can do that by using the following (If you are unsure if you have anything else using java in the background you may want to skip the ‘killall java’ line):

killall Xvfb
killall java

Test the scripts out now by running (in the init.d directory):

./xvfb start
./selenium start

To get these running on start-up use the following commands:

update-rc.d xvfb defaults 10
update-rc.d selenium defaults 

You’re now ready to get continually integrated.

Getting Thrift & Scribe working with OSX

I googled out a whole slew of write-ups on getting thrift and scribe working on OSX and I finally cobbled together something that works.  I’m sure of dependancies may/will change so YMMV following these steps.

First off, if you don’t already, install Macports.

In terminal type:

sudo port selfupdate
sudo port install boost
sudo port install pkgconfig
sudo port install libevent

Note: I read somewhere that libevent needs to be compiled not, installed through Macports, so I did both but doubt compiliing it was necessary.  Also the ‘install boost’ section took me nearly an hour to fully build.

Grab thrift.  Before doing any installing, you need to do this one step within the thrift directory:

cp /opt/local/share/aclocal/pkg.m4 aclocal

In the thrift directory run:

./bootstrap.sh
./configure --with-libevent=/opt/local
make
sudo make install

Now it’s on to Scribe. Grab scribe.

./bootstrap.sh
./configure
make
sudo make install

Alright, if all goes well you’ll have scribe and thrift now running. To double check follow these steps from http://bzilla.org/running-scribe-on-osx (it was down when I found it, so I grabbed this portion of text from Google cache and pasted it here):

Testing

Now that you have successfully installed Scribe and its pre-reqs you can test it out. For testing purposes you can follow the steps outlined in <scribe dir>/examples/README.

You may encounter an error when running scribe_cat and/or scribe_ctrl that looks something like:

  • ImportError: No module named scribe
  • ImportError: No module named fb303_scripts

First, make sure you ran the make install target for Thrift, FB303 and Scribe. If you confirm installation of all the libraries and you still are having import errors you’ll want to create symlinks for Python (I’ve tried exporting PYTHONHOME as well as creating a .pth file in the examples folder with no luck). Execute the following from the /Library/Python/2.5/site-packages/ directory:

  • ln -s /usr/lib/python2.5/site-packages/fb303 fb303
  • /usr/lib/python2.5/site-packages/fb303_scripts/ fb303_scripts
  • ln -s /usr/lib/python2.5/site-packages/thrift/ thrift
  • ln -s /usr/lib/python2.5/site-packages/scribe scribe

You should now be able to run the examples.