michaeldehaan.net

It’s Not Just About Llamas

Vim Setup For Working With Large Codebases

with 2 comments

Vim is awesome for working with small projects where you know where everything is. What if you don’t? Here’s my current setup, as a form of backup. Hopefully this is useful to someone else as well.

ctags setup:

#!/bin/sh
cd basedev
ctags -R --totals=yes --tag-relative=yes \
        --extra=+f \
        --PHP-kinds=+cf \
        --regex-PHP='/abstract class ([^ ]*)/\1/c/' \
        --regex-PHP='/interface ([^ ]*)/\1/c/' \
        --regex-PHP='/(public |static |abstract |protected |private )+\s*function\s+([^ (]*)/\2/f/'

.vimrc:

nmap <C-f> :NERDTreeToggle<CR>
nmap <C-b> :BufExplorer<CR>
nmap <C-t> :TlistToggle<CR>

Installed VIM plugins:

So to open a file in the source tree, I can just:

cd ~/code/basedev
:tag SomeClassName

And then the rest of my workflow is:

Control+f   = Toggle the file explorer tree
Control+b  = Pick an open file to edit
Control+t   = List functions in the file  (Control+w to change windows)
Control+]   = Jump to tag under cursor
:Ack Foo   = Look for files that contain Foo and potentially open them

All of this works without dealing with vim split windows or tabs, which are, IMHO, both very annoying.

Simple, and works. And, best of all, it is not Eclipse.

Suggestions on your other favorite vim plugins are very welcome. While Ack is nice on the command line, I think there are probably better file search plugins for vim that people prefer?. I am not using any “project” style plugins at the moment. My workflow for remembering a workspace is, so far, writing down the names of classes I’ve found along the way that might be worth remembering, and opening them again with “:tag Foo” as needed. I’ll edit this page over time to reflect my current setup.

Written by mpdehaan

November 10, 2009 at 10:07 pm

Posted in linux

Where’s mdehaan?

with 2 comments

So as I promised details — Monday I started my new job at Lulu, a whole 5 minutes away from my previous work. I’m still getting used to things, but it is nice in many ways to be doing somethings completely different after having spent about 8 years doing systems management (not all at Red Hat). It is exciting to be doing product work again (as with Integrian) as it’s the kind of work you can explain to regular people you meet on the street and can make a considerable impact. Also, the whole public “dotcom” thing is newness. I’ll probably miss the OSS conference circuit a good bit, but it is otherwise a welcome change, and I was growing a bit tired of speaking on the same subjects anyway — as I suspect you were growing tired of hearing them :) While Lulu is not in the Open Source business directly, the “democratizing content / community” theme from Red Hat still remains… letting anyone write and print books is a great concept.

Immediately noticed things — Being on 40 less IRC channels and 40 less mailing lists, and some several thousand less emails and chat pings a day. I find myself able to work near continuously instead of fire-fighting every 5-10 minutes, and that is a very good feeling. Queue some comments from Paul Graham. Also working with everyone in the same office was long missed, as there’s a definite bandwidth loss in email and IRC communication that goes along with the disruption factor those mechanisms induce — plus the lost exchange of “have you seen this cool thing”, etc. Lulu has a very cool office, having the restored Carolina Equipment Building — all exposed bricks, wood, and a tractor sign on the top. Parking within sight of Sullivan, the Ballfields, and U.T. is a little strange though :)

Also, I’m still using Fedora as a development environment, which is goodness. I expect to still be submitting some bugs, so hide while you can!

Written by mpdehaan

November 7, 2009 at 1:23 am

Posted in Uncategorized

Game of Life on A Rubik’s Cube, and Other Weirdness

leave a comment »

From a random discussion at work (spawned from my de-stickered already-been-solved Rubik’s Cube), I think someone should build something like this:

Imagine Conway’s Game of Life (GOL) being played on all six surfaces of a connected Rubik’s Cube (RK) covered with LEDs, such that formations could travel across the edges of a face and onto the other edges. Each GOL cubeface is, say, arbitrary MxM, for instance 99×99 — however each twistable cube portion is only 33×33. As a result, if the microcosm traversing the surface of the cube were to stagnate, it could be radically altered with a twist of the cube and drastically alter the game state. This could be a quite interesting piece of art.

An alternative simulation requires contextually aware e-paper, which is much more technologically complicated, because currently such things don’t know where every “pixel” of the paper resides in 3D space. Anyway, suppose there is a GOL being played on a MxN sheet of paper (perhaps both sides), that is totally flexible. Imagine if it could be folded to connect various portions of the page, such as to temporarily form a tube, or folded in various shapes. Further, imagine the following with multiple sheets of contextually aware e-paper, so if you picked up two GOLs and set them together, a creature from one would have a chance to travel to an adjacent page.

We all agreed that GOL in itself was not super-interesting, though I think the idea of cellular automata (or possibly even some form of e-pets) that could move between various surfaces could be pretty neat. A related concept could involve wearing an e-shirt and leaning up against an e-wall with your e-shirt. Just like a “wet paint” scenario, some of the advertisements living on the wall could crawl onto your shirt until you shook it off. Similary, assume a GOL type automata living on your shirt interacting with a GOL automata living on the wall, or having a clean “white” shirt that gets a GOL automata on it by standing too close to the wall. Careful what walls you lean on, you could upset the equilibrium of a wall and kill it… and it might take someone else leaning on the wall to bring it back.

Written by mpdehaan

November 6, 2009 at 1:14 am

Posted in Uncategorized

Vim Rsync Hooks — Remotely Copy Certain Files Upon Save

with 2 comments

Challenge: Have local files in a developer setup for quick searching of a large tree of code, but mirror them to a remote test server any time they are edited, since your local development platform is not your test platform.

Solution: vim post hooks! Note that this is a work in progress.

/usr/bin/vim_mirror.py:

#!/usr/bin/python

import sys
import os
import subprocess

REMOTE_ROOT="user@host:/path/to/somedir"

if __name__ == "__main__":

   if len(sys.argv) > 1:
      tokens = sys.argv[1].split("/")
      # as implemented this script will ONLY mirror all files rooted in "/basedev"
      # to a given remote root... this will need to be tweaked for different
      # developer setups in a future version of this script.   Ideally it will take a list
      if tokens[0] == '' and tokens[1] == "basedev":
          local_file = sys.argv[1]
          remote_part = "/".join(tokens[2:])
          cmd = "rsync %s %s/%s" % (local_file, REMOTE_ROOT, remote_part)
          print cmd
          subprocess.call(cmd, shell=True)

.vimrc:

au BufWritePost * :!/usr/bin/vim_mirror.py %:p

Written by mpdehaan

November 5, 2009 at 11:20 pm

Posted in Uncategorized

Telephoto Panoramas at f/1.2

leave a comment »

This test shot was taken of about 100 pictures (in JPG mode, not RAW) though I screwed up and due to not taking enough pictures, is really composed of only about 40. Each was shot at f/1.2 (manual focus) from the same point, and merged in autostitch, simulating something like a 18mm f/0.5 or something similarly crazy. I have no idea on the math, but that’s just not possible with a wide angle — wide angle lenses just get horribly wide depth of field because of, well, physics. Further, there’s no way the glass in those is anywhere as good as the 85mm f/1.2 — hardly anything is. I need to try some more of this later, but I see much potential in it. Shooting panoramas with this camera is much much easier than with the infared camera or point-and-shoot, since the shutter is a LOT faster. I think this is more interesting than normal wide angles, and ends up being cheaper as well!

Written by mpdehaan

October 31, 2009 at 10:57 pm

Posted in Uncategorized

Fall at f/1.2

leave a comment »

This tree picture is from a trip to Duke Gardens today, which turned out really nice — it had just stopped raining (so everything was wet, which is good), it was not too bright, and it wasn’t very crowded. Never mind that everyone there was taking pictures of the same tree, I was packing a 85mm f/1.2, and they weren’t :)

More in the photo gallery linked above.

Written by mpdehaan

October 31, 2009 at 7:46 pm

Posted in Uncategorized

Welcome To My Nightmare

leave a comment »

I have some ideas for an ironic haunted house — it will be composed as a series of deep and meaningful vignettes, built out in the greatest of detail. Behold:

Room one. A darkened living room, as commonly found in any house across America. A TV in the corner, slightly flickering, still running standard definition. On the TV, a Kern Burns documentary — perhaps the one about baseball or jazz, it really does not matter. There is a box set nearby — one of ten, or so. This will be on for a looong loong time. Slowly, black and white photos pan across the screen as a monotone narator rambles on.

Room two. A public library. The labels on the shelves show that we are in the Science-Fiction/Fantasy/Horror section. On a closer glance, all of the books in the library relate to developing J2EE applications.

Room three. The milk/juice aisle of a grocery store. Everything is fully stocked, except the orange juice. There is only the generic orange juice left, not the brand you actually get/like.

Room four. An outside scene. The viewers are in a city, and there is a traffic circle. That is all.

Room five. An middle or high school classroom full of wooden desks. There are no students, but at each desk there is a 750 question scan-tron exam where you have to bubble in the answers as well as also bubbling in your name and social security number. There is a single pencil, which is dull, too short, and has a badly worn eraser.

Room six. A corporate computer lab, full of computers, with very long ethernet cables coming out of each one of them. They all run into various switches which are plugged into one another (more than once!!!), and are otherwise tangled and hard to trace. Some cables are badly twisted and perhaps damaged. All the lights on the switches blink in insane patterns, evoking a discotheque, though the only noise comes from the humming of computer fans and the 60Hz drone of fluorescent lighting. Very few machines have network connectivity.

Room seven. A DMV. There is no line, leading viewers to the suspicion that something is deeply wrong.

Room eight. A modern science museum. This is an exhibit about dinosaurs. The plaque above one of them reads “Brontosaurus”.

Room nine. A Barnes and Noble. There are no chairs.

Room ten. A large indoor swimming pool, empty of people, but full of water. A sign reads “beware invisible great white shark”. However, being invisible, you wonder if it’s really white or not. There is a penny on the bottom of the pool.

Room eleven. A kitchen counter, with some bananas and other fruit in a bowl. The faces on the bananas are very very angry.

Room twelve. A hole from a miniature golf course. There is a ball and a putter, and the greens are well manicured. There is no hole.

Room thirteen. Inside a Bojangles. There are two contains of tea in the corner, made for refills, one large and one small. Both are labeled “unsweet”.

Room fourteen. A college math classroom. On the board, there is a problem involving flux integrals through nth-dimensional hypersolids. There is also a real live llama. It is unclear whether the llama is related to the math problem or not.

John Carpenter, call me.

Written by mpdehaan

October 31, 2009 at 6:48 pm

Posted in Uncategorized

A Very Short Halloween Playlist

with 2 comments

Putting stuff together for the iPod. Behold:

AC/DC — Hells Bells
CCR — I Put A Spell On You, Bad Moon Rising, Walking On The Water, Tombstone Shadow
Warren Zevon — Werewolves of London, Roland the Headless Thompson Gunner
Van Halen — Hang Em High, Runnin’ With the Devil
Eagles — Hotel California (Acoustic)
Cream — Crossroads
Surfjan Stevens — They Are Night Zombies!! They Are Neighbors!! …
Santana — Black Magic Woman / Gypsy Queen
Rainbow — Gates of Babylon, Man on the Silver Mountain
Edgar Winter Group — Frankenstein
Queenrsyche — Queen of the Reich, Warning
Pantera — Cemetary Gates, Cowboys From Hell
The Outlaws — (Ghost) Riders In The Sky
Iron Maiden — The Evil That Men Do, Only The Good Die Young, The Wicker Man
Focus — Hocus Pocus
Alice Cooper — Welcome To My Nightmare
Deep Purple — Stormbringer, Burn, Fireball
Black Sabbath — Heaven And Hell, Lady Evil, Neon Knights
Jimi Hendrix — Voodoo Child (Slight Return)

Written by mpdehaan

October 28, 2009 at 10:02 pm

Posted in Uncategorized

Sodapop and Ritalin

leave a comment »

Due to some bad luck with rain/clouds, my best shot at the Beach was a Green Day sticker on a Speed Limit Sign. Fortunately, I like things like this.

Written by mpdehaan

October 27, 2009 at 6:45 pm

Posted in Uncategorized

WordPress/Twitter Integration

leave a comment »

WordTube posts should now show up on my TweetSphere automatically. And there was much rejoicing.

[details for those using wordpress.com]

Written by mpdehaan

October 23, 2009 at 4:05 pm

Posted in Uncategorized