ERLANG CODE AUTO RELOADER - AUTO RUN UNIT TESTS AND HOT LOAD CODE AFTER A BUILD

I wrote this post a few months ago when I was developing a new Erlang application. I eventually ended up using the reloader I mentioned at the end, but never documented it. Now I’m about to start writing a new app, and I’m on a different machine. First, get the reloader. It was developed as part of mochiweb but functions just fine on it’s own. Just put it somewhere accessible - I use the ebin directory in my home folder.

READYNAS RSYNC TUTORIAL

The NETGEAR ReadyNAS is a pretty sweet product if you’ve got a small team like I do. It’s inexpensive and easy to set up. Log into the ReadyNAS and turn on Rsync for your backup share. Optionally, set a username and password. Your ReadyNAS will start up it’s rsync daemon. Replace the password and IP below with the rsync password and IP of your NAS, and use the share name in the rsync command - mine was “backup”.

SETTING UP NAT PORT FORWARDING WITH VIRTUALBOX

I’ve typically used bridged networking with VirtualBox, but you can run into some issues. If you’re somewhere without internet access, or if you’re changing IPs often, you might be better off using NAT settings. There’s a few other advantages - for instance you won’t need to check the IP of your machine in order to connect to it over SSH. It’ll just work. Sweetness. To get started, your VM must be shut down.

CUSTOMIZE TAGLIST PLUGIN DISPLAY

I’ve hopped back on the VIM train recently, and I’m loving it. Command-T, NERDTree, buffer explorer and fixing my fonts in MacVIM ( set guifont=Inconsolata:h16 ) have all been essential to the move. That and the INSANELY helpful folks in #vim on freenode. I just read the VIM book cover to cover. Extremely useful. I recommend it. The latest thing I figured out I wanted was to make better use of ctags.

SETTING UP DEFAULT CRON PATH

I’ve run into a ton of issues working with crons, mostly with the $PATH variable screwing things up. Scripts work when run manually on the command line, but fail when run in cron. Very annoying. I’ve asked a bunch of Linux sys admins how to fix this - and the answer is always “put the full path in your scripts” which to me in unacceptable as it introduces the possibility of human error.

SMARTER ERLANG PROGRAMMING WITH EMAKEFILE OPTIONS AND USER_DEFAULT

Say you’ve got an Erlang app with the standard file system layout, with your source code in src/ and your compiled code in ebin/. I’ve found this makes using the interactive shell interpreter a little harder. Lets use the Emakefile that Erlang supports to let us recompile and reload our code on the fly. Create a file called Emakefile, and put the below line in it. There’s other options, but this keeps things simple.

BLANK MYSQL GRAPHS IN MUNIN

From the Munin FAQ Q: Why are the graphs for the MySQL plugin blank? This is due to a bug in a Perl library Munin uses which causes $PATH to be lost. This again causes the plugin to not find the mysqladmin program which it needs to retrive the numbers the needed in the graphs. The solution is to hardcode the path of the program. First locate the mysqladmin program. On most systems, the command which mysqladmin, type mysqladmin or locate mysqladmin will help you.

GIT - WHAT CHANGED BETWEEN PUSHES?

There’s an overwhelming amount of git tools, and if you’re coming from SVN you might expect that the tools w/ the same names work the same way. You’d be wrong. Because of Git’s distributed nature, you can (and frequently do) have commits in your repo that you might not have pushed up. You might also have forgotten what they were. Good thing there’s a tool to check that. Lets assume you’re on your master branch, and you’re comparing against the origin remote repo.

UIS PHP53, DOM PARSING, PHPUNIT, PUPPET CONFIG SOLUTION

I’m using PHP53 package from the IUS Community repository. I’ve been trying to get phpunit to install, but it gives an error that it needs DOM install. It took me a little bit to figure this out, but I finally got it working. What you need is the php53-xml package. You can install it using yum install php53-xml or if you’re using puppet package { ["php53-xml"]: ensure => present } And finally, to get it to install, I used the below.

DEBUGGING WITH ERLANG

First, make sure you have the compile flag (+debug_info) set when compiling your source, then fire up the debugger: 1> i:im(). My Erlang Makefile: EBIN_DIR := ebin SRC_DIR := src EXAMPLES_DIR := examples INCLUDE_DIR := include ERLC := erlc ERLC_FLAGS := +debug_info +native -W -I $(INCLUDE_DIR) -o $(EBIN_DIR) all: @mkdir -p $(EBIN_DIR) $(ERLC) $(ERLC_FLAGS) $(SRC_DIR)/.erl clean: @rm -rf $(EBIN_DIR)/ @rm -f erl_crash.dump Read up on the Erlang docs. The debugger can be a bit weird in that it doesn’t always find your ebin directory (if you’re compiling to a separate ebin dir)… it took me a bit to figure out.