Skip to main content


Showing posts from May, 2007

Erlang: The Amazingly Funky and the Amazingly Cool

Anyone who's ever looked at Erlang knows that the syntax is downright strange . For instance, Python uses "#" for comments, but Erlang interprets "8#7" as 7 in base 8 notation. Python uses "%" for modulo, but Erlang uses "%" for comments. Erlang uses "rem" for modulo, but "rem" is used as a comment delimiter in some other syntaxes. However, I ran across some other cool tidbits. If M is a 16 bit binary value, you can unpack the first 3 bits into X, the next 7 bits into Y, and the last 6 bits into Z using the syntax: <<X:3, Y:7, Z:6>> = M Hence, you can parse an IPv4 datagram in a single pattern-matching operation (taken from "Programming Erlang: Software for a Concurrent World" p. 99): -define(IP_VERSION, 4). -define(IP_MIN_HDR_LEN, 5). ... DgramSize = size(Dgram), case Dgram of <<?IP_VERSION:4, HLen:4, SrvcType:8, TotLen:16, ID:16, Flgs:3, FragOff:13, TTL:8, Proto:8, HdrChkSum:16,

Vim: More Tips

If you've been following along with all my ramblings about Vim, you may enjoy this other guy's rambling about Vim. I learned: Re-indenting: == Re-indent current line. <motion>= Re-indent block. Grepping in vim: :grep -r vim . :cn Display the next grep finding. :cp Display the previous grep finding. :cw Open the QuickFix window to get an overview over the results. ^d Use this instead of tab completion to see all the options. :set spell Turn on the spell checker.

OS X: Aquamacs

I am a die hard Vim fanatic, as many of you know. I actually like modal editing. However, in the Erlang world, everyone seems to use Emacs, and the Erlang mode for Emacs is quite advanced. The practical thing to do is to use Emacs for Erlang and Vim (since I like it so much) for everything else. The only problem is that every time I learn something in Emacs, I tend to forget something in Vim ;) Yes, my brain is that small! Fortunately, Bob Ippolito introduced me to Aquamacs , an easy-to-use, Mac-style Emacs for Mac OS X. Being a GUI guy, I was immediately pleased to see the nice Cocoa interface. (This is one thing I always liked about Vim, there's a native version of GVim for each operating system.) However, what's even better is that they've gone to great pains to make Emacs feel natural for OS X users. All the normal Apple shortcuts work. Even though I've taken the Emacs tutorial a quarter dozen times, using Aquamacs, I felt more productive almost instant

O'Reilly Code Quiz

I took O'Reilly's code quiz . It was kind of nerve racking to try to answer questions quickly, but it was a lot of fun! As usual, my accuracy was pretty high, but I took too long.