My First Erlang Program

I’ve been looking for some elementary ‘puzzles’ to code up in Erlang so I can figure out the language a bit. In passing, I came across Facebook’s “Programming Puzzles” page.

So today, the rest of the family went to a birthday party and I stayed home to solve the first puzzle and get my hands dirty with some Erlang.

Here is the resulting code….

-module(hoppity_hop).

-export([ handle_file/1 ]).

handle_file(Fname) ->
    case file:read_file(Fname) of
        {ok, FData} ->
            parse(FData);
        {error, Reason} ->
            {error, Reason}
    end.

parse(Bin) ->
    do_hoppity_hop(lists:seq(1,list_to_integer(lists:nth(1,string:tokens(binary_to_list(Bin)," \t\r\n"))))).

do_hoppity_hop([Head|Tail]) when Head rem 5 == 0, Head rem 3 == 0 ->
    io:format('Hop~n',[]),
    do_hoppity_hop(Tail);

do_hoppity_hop([Head|Tail]) when Head rem 3 == 0 ->
    io:format('Hoppity~n',[]),
    do_hoppity_hop(Tail);

do_hoppity_hop([Head|Tail]) when Head rem 5 == 0 ->
    io:format('Hophop~n',[]),
    do_hoppity_hop(Tail);

do_hoppity_hop([Head|Tail]) ->
    do_hoppity_hop(Tail);

do_hoppity_hop([]) -> false.

If anyone has any feedback, I’d love to hear it. This is the first time I sat down and actually wrote anything in Erlang, so I won’t be offended. :-)

I should probably write a quick python version too, just so I know that skill set isn’t totally wasting away. ;-)

Splitting Nagios Alerts Up and Sending Them to an Alltel Phone via SMS

This is pretty old code. I no longer know if it works, but I was going through some old Interlix, LLC equipment and found it, so I figured I’d share it.

alltel_msg.py

RailsConf

This was my first RailsConf. I figured it would be bigger for some reason. In retrospect I’m not sure why I originally thought that. It was bigger than the last conference I went to, which was PyCon 2007.

I didn’t get to go to many of the talks I wanted to go to, mostly because I was spending time either working on the Engine Yard Express Image, at the booth talking with customers and potential customers or chatting with other Engine Yard Employees I hadn’t met face to face before.

It was really cool to meet various customers that I’ve worked with previously. I also finally got to meet David Chelimsky face to face. I’ve worked with him for a while now via Articulatedman, who was a customer of Interlix, my old hosting company.

Ezra announced the Engine Yard Express image and Vertebra at his talk. Since they’re now public I’ll probably start blogging about both of those projects from time to time. Finally. :-)

If anyone starts using the Engine Yard Express image and has any problems, comments or suggestions, please email me @ work … emuller (at) engineyard (.dot.) com.

Twitter Updates for 2008-04-13

  • I just realized that I slept a crap load last week. #
  • @wayneeseguin inflating? #
  • Ohhhh shiney: Vectrix electric motorcycle #

Powered by Twitter Tools.

Time Machine Primer

http://earthlingsoft.net/ssp/blog/2008/03/x5_time_machine