brool

brool \brool\ (n.) : a low roar; a deep murmur or humming

Author Archive

Haskell To WordPress (Snippet)

Friday, April 10th, 2009
A small snippet of code that demonstrates calling into a WordPress XML-RPC server with Haskell and HaxR. [code lang="haskell"] import qualified Data.Map as Map import Data.Maybe import Network.XmlRpc.Client import Network.XmlRpc.Internals server = "http://yourserver.wordpress.com/xmlrpc.php" -- extract multiple posts from the XML response extract :: Value -> [Map String Value] extract xmlresp = let ValueArray rs = [...]

Haskell Performance: Array Creation

Sunday, March 29th, 2009
Ran into another interesting performance problem while converting a small test program over to Haskell. Let’s say that you want to walk through every line of a text file, collate character frequencies, and return anything that maps to a particular frequency. For purposes of explanation we’ll do something really silly like look for lines with [...]

Haskell Performance: Lowercase

Saturday, March 28th, 2009
I was trying to track down some issues with some text processing programs that I was writing in Haskell, and ran into an interesting problem. I made one small change and my program ended up being 5 times slower, and I had to backtrack to try and find out what it was. So, given a [...]

Using MissingPy

Thursday, March 19th, 2009
For comparison purposes, I was rewriting the silly little e-mail digest program in Haskell, using Python libraries for the IMAP interface (it’s available on Github). It’s hard to beat Python’s amazing collection of libraries. Cabal / hackage isn’t bad, but it doesn’t yet approach Python’s “batteries included” philosophy and ease of use. Anyway, I couldn’t [...]

Python to Haskell (String Functions)

Wednesday, February 25th, 2009
I will be updating this as I go… but see also the Wikipedia page on string functions in various languages. Joining a string list [code lang='haskell'] -- Python: ",".join(lst) -- either... import Data.List intercalate "," lst -- or... import Data.List concat (intersperse "," lst) [/code] Splitting on a string [code lang='haskell'] -- a.split(ss) -- You [...]

State Monads in Haskell

Tuesday, February 24th, 2009
I would like Haskell better if it didn’t do its best to make me feel stupid. Tasks that are easy in other languages, such, say, maintaining some state or generating a random number, become difficult. After banging my head on the State monad I finally arrived at a kind of understanding, which I put here [...]

Recovering A Trashed Ext3 System

Tuesday, February 10th, 2009
My 500GB backup drive started making horrible, horrible noises when spinning up, akin to a lawnmower trying to mow a rock, so I decided that it was time get another backup drive so that I would be safe. I picked up another drive at Fry’s (not a Maxtor this time, thank you very much; I [...]

Mysteriously Hanging Ubuntu

Friday, January 2nd, 2009
My Asus EEE 1000h had this really irritating but intermittent bug — it would hang occasionally when I was using it. The keyboard was dead, but a) mouse clicks would still work, and b) I could Ctrl-Alt-Backspace to restart X or Ctrl-Alt-Fn to go to a terminal. So, it wasn’t an absolute showstopper, but it [...]

Setting up an Alix

Thursday, January 1st, 2009
Updated 2010-02-04: You know, in reading this over, I think this came out as a little harsh on the Alix. I stuck that tiny Alix board in an old box, put it under my TV, and it’s been running for two years with absolutely no problems. Over time, it’s gotten more and more stuff put [...]

Creating Mail Digests with Python and IMAP

Sunday, December 28th, 2008
There should be a word for “effort undertaken even though you’re sure, somewhere, somebody has written something for it already, or maybe it’s already a Linux command.” I get the distinct feeling that this utility already exists, but I googled to no avail. I have a bunch of e-mail boxes, some incredibly infrequently used, but [...]

Parsing Tables With Beautiful Soup

Saturday, September 27th, 2008
Just a quick snippet, since it is obvious after writing it but was not obvious while searching for it: [code lang="python"] html = file("whatever.html") soup = BeautifulSoup(html) t = soup.find(id=label) dat = [ map(str, row.findAll("td")) for row in t.findAll("tr") ] [/code] … or, map a different function is you need to further parse the individual [...]

Poison Reverts in Git

Friday, August 22nd, 2008
Alice owns the main branch that a bunch of people are using: A — B — C — D Bob checks it out, makes changes 0..2, and does regular pulls: A — B — 0 — 1 — C — 2 — D Now, Alice pulls Bob’s stuff: she has A — B — C [...]

Ocaml Sockets

Monday, June 23rd, 2008
There seems to be one standard library in Ocaml for dealing with HTTP, and that’s Ocamlnet. Ocamlnet suffers from a few problems, the chief of which is it’s difficult to set up unless you use something like GODI to install your packages. (Sadly, this is one thing that Ocaml is still not very strong at; [...]

Fedora 9 On EEE (and: Ubuntu Is Not Always The Answer)

Wednesday, June 4th, 2008
I used to use Red Hat back when I had to compile special modules for my CD-ROM player, and I flirted with Gentoo for a while until I managed to irretrievably kill my installation with an emerge, but Ubuntu really seems to hit the sweet spot with regards to ease of use and functionality. However, [...]

That Which Drives Developers To Piracy

Thursday, May 29th, 2008
I bought Photoshop CS3, since I am seriously into photography and Gimp is too painful to use. So, all was fine for about one week on my Windows XP installation, and then it stopped working — it would just lock on startup, no error message, no status dialog. Googling around didn’t reveal anything that could [...]

Quick iPhone Trick — Easy Access To PDFs

Wednesday, March 19th, 2008
A quick hack that I didn’t see elsewhere but is too easy and fast not to mention — currently, there isn’t a great method of storing files on the iPhone. I keep a bunch of papers around in PDF format that I like having available whenever I’m standing in line or whatnot. You can potentially [...]

The Tiniest Lisp (in Python)

Tuesday, February 19th, 2008
I was inspired by a link I had found on LtU: the Lisp 1.5 reference manual. If you look at page 13 you will see a simple definition of the core of Lisp. Really, it’s beautiful. Accordingly, I spent a bit of time implementing the simplest possible Lisp in Python — it’s very tiny, only [...]

DNS Tunneling (on Mac OS X)

Saturday, February 9th, 2008
The instructions were spread about and a bit unclear in some circumstances… so a simple step by step guide to using DNS tunneling under Mac OS X: What You Need A server for which you have sudo access and control over the DNS records A client on which you have sudo access Setting Up The [...]

Debugging Threading Problems in Python

Saturday, March 3rd, 2007
I was debugging a threading problem in someone else’s code the other day, and found it difficult to get a picture of what was happening. The problem with threads, you see, is that most languages make it very easy, which tempts programmers to use them and causes no end of problems later. Instead of being [...]

Recursive Types In Ocaml

Wednesday, February 21st, 2007
A question came up at lunch today that was kind of interesting: in a strongly-typed language, what is the type of a function that takes a list of functions like itself? Of course, such a thing is easy to write in Python, since everything is dynamic: [code lang='python'] def p0(aList): print "p0" if aList: (aList[0])(aList[1:]) [...]