Wednesday, January 30, 2008

OEDILF Google Widget


I've been wanting a way to link my OEDILF contributions to my blog and finally got around to figuring out how. The result is a Google Gadget that displays OEDILF limericks! I had a blast making this. What is so exciting about using Google's API is that it really makes you feel like you are programming on a grand scale. They have the distribution channel and the libraries all there. You just need an idea. Anyway, to cut to the chase, here is how to embed my gadget onto your blog (it is a bit clunky to do this because using gadgets in blogger is a bit of a new thing):

  1. Since the feature that allows putting google gadgets into blogger is still very new you need to log into your blog via this URL.
  2. Go to Template > Add a Page Element > Gadget (Add to Blog) > Add your own
  3. Then paste in this url http://hosting.gmodules.com/ig/gadgets/file/113358134765646390343/oedilf.xml
By default the gadget will pull down the most recent 20 approved OEDILF limericks and display a random one from that set. You can turn off the randomization so it always displays the latest submission. You can also enter a particular author's OEDILF ID to get a stream of just the limericks from that author.

Here is a button that will add the gadget directly to your iGoogle home page. Add to Google

If you are interested in how all this works you can view the code for this gadget here. And here is a link to the gadget API. The library is pretty nice and makes things like grabbing RSS feeds a piece of cake. Happy coding, or limericking, whatever you plan to do after reading this. Edit: 1/30/08 - Gadget checked into subversion. Project page is here.

Monday, January 21, 2008

LOLcats begat LOLsaints

Ben Burrns documentary on the history of the LOLcat phenomena exposes an ugly chapter in history: the censorship of LOLcats past. Had Ben made this a multi-part documentary he might have got round to the discussion of how the LOLcats begat the LOLsaints. It would have fit right in there with the LOLcat on the Sistine Chapel ceiling.

Thursday, January 17, 2008

Syntax Highlight 'Hello World' in Blogger

#I've been wanting syntax highlighting for my code samples for awhile
#But blogger doesn't give you anything special for doing it
#The references section at the bottom of this post has links to blogs
#that describe how to get highlighting for ruby, xml, and yaml. It is a start.

#Ruby code syntax highlight example
class Say
def self.hello
puts 'hello world'
end
end

Say.hello

#References:
#http://blog.wolfman.com/articles/2006/05/26/howto-format-ruby-code-for-blogs
#http://blog.michaelgreenly.com/2007/12/blog-post.html

Bash and Vim on OS X 1.5


2008-01-23: I have updated this post with better information. Pardon me not updating the screenshots to show the red highlighting against the directories. I recently got a MacBook Pro. Yes I like it; no I don't think it is better than a Gnu/Linux system; they are both good in different ways. One immediate problem I had was that, in bash, the ls command didn't highlight files, directories or links with different colors. The quick solution to this is to alias your ls command to be ls -G. This works unless you are like me and want a lovely dark background for the terminal. They use blue for the directory color and I can't see the blue against black. I want it to be red. Of course it is just a matter of knowing what config files to tweak... Here is a boring post about getting that done.

In order to change this behavior you need to have a local preferences file for bash. You might already have one. I didn't have a .bash_profile .profile or .bashrc so I created a file called .profile that contained the following.

export TERM=xterm-color
export CLICOLOR=true
export LSCOLORS=bxfxcxdxbxegedabagacad
#alias ls='ls -G'

To understand what that means look here for a full discussion. It is probably also documented in the man pages somewhere. To get the highlighting to take effect without restarting your terminal just type 'source .profile' without the quotes.

Now what about the prompt itself? Wouldn't it be nice if that worked like an ubuntu prompt? I like how ubuntu gives you your current position in the directory structure as part of the title of the terminal window. With a little more magic we can make this happen as well. Add this to your .profile to see what I mean:

TITLEBAR='\[\e]0;\u@\h:\w \a\]'
export PS1=${TITLEBAR}'\u@\H:\W\[\e[37;1m\]$ \[\e[0m\]'
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
#export DISPLAY=:0.0

If you want to know what all that garbage means you can read the man pages or refer to these nice tutorials here and here.

My other hangup was getting vim to work properly. I wanted syntax highlighting, line numbers, auto indentation and other bells and whistles. No problem, once again it is just a matter of knowing the config files. I created a .vimrc in my home directory and put the following into it.


set nu " Line numbers on
set nowrap " Line wrapping off
" Formatting (some of these are for coding in C and C++)
set ts=2 " Tabs are 2 spaces
set bs=2 " Backspace over everything in insert mode
set shiftwidth=2 " Tabs under smart indent
set autoindent
set smarttab

" Visual
set showmatch " Show matching brackets.
set mat=5 " Bracket blinking.
set background=dark
syntax on

Now things are much better. Be advised that all these settings are for dark terminal backgrounds. I use the "homebrew" theme for terminal. Make sure you set it as your default or subsequent tabs will open up with some other theme.

References:
  • http://www.macosxhints.com/article.php?story=20031025162727485
  • http://www.funtoo.org/en/articles/linux/tips/prompt/
  • http://www.macworld.com/article/50257/2006/04/bashprompt.html
  • http://forums.macrumors.com/showthread.php?t=171291
  • http://systhread.net/texts/200703bashish.php
  • http://biodegradablegeek.com/2007/12/13/using-vim-as-a-complete-ruby-on-rails-ide/

Saturday, January 12, 2008

Wii + Mac = Drumkit

I just ran across this video and it is absolutely brilliant! They call it the Wiinstrument. There is a GNU/Linux version here, thank you very much. The next bit of work that needs to be done is to map the kick drum sound to my keyboard. With the keyboard on the ground I'll be able to tap out some dirty little bass rhythms with my foot. Presto, I have a full on drumkit!

Friday, January 4, 2008

Race and IQ Cartoon

This is a fantastic cartoon by Ruben Bolling deriding racist notions about intelligence. You can read more on this topic here. The Wikipedia article lists two controversial assumptions that modern theories on race and intelligence make. The one I most take issue with is is the notion that "intelligence is quantitatively measurable by modern tests and is dominated by a unitary general intelligence factor" It seems fundamentally wrong to assume something as complex and multi-dimensional as intelligence can be assigned a numerical value. Step 4 of the experiment proposed in this cartoon makes a good point too. These tests, in order for them to work, have to be designed for a particular person. If there are questions on the test in Shakespearian English then Shakespeare or somebody very familiar with his language will clearly be judged by that test to be the most intelligent. If there are questions on the test about late 80's sitcoms then people who know names like Mark-Paul Gosselaar, Dustin Diamond, Lark Voorhies, and Dennis Haskins will be judged to be intelligent. Thus, these tests test for an arbitrary notion of intelligence. In my opinion that is a pretty worthless thing to be testing for and it makes it easy to see how the opinions and bias of the people creating these tests would show up in the results. Basically the test tells more about the person who created it than the person who takes it.

Concise History of Black-White Relations in the U.S.A.



I really like this cartoon. I first saw it on this blog I occasionally read. But it was originally posted by the cartoonist (whose real name I can't find) right here.

Wednesday, January 2, 2008

Disk Usage Analyzer


Have you ever wondered where that other 140GB of your Hard Disk went to? For ages I have relied on the venerable "du -sh *" command or the "df -h" command to answer me that question. Today after a conversation with a colleague who uses GrandPerspective on his Mac I felt obligated to find the Linux answer to GrandPerspective. I quickly stumbled upon Baobab which is Gnome's answer. It is bundled with Ubuntu and can be found under applications > accessories > disk usage analyzer. The Baobab idiom for displaying your disk usage is, in my mind, nicer than the Treemap used by GrandPerspective. As the picture indicates it displays your folders in this cylindrical graph. What the picture doesn't show is that it is interactive, so you can hover over a particular part of the graph and get the folder name and size. I also like the listing of directories down the left side which are ordered by size. The killer feature is that it will let you scan remote drives via samba, ssh, ftp or whatever.

Now that I am done writing this up I find myself wondering why I even bothered with this. My command line judo clearly solved the problem at hand. It was only a moment of insecurity that obliged me to prove once again that Gnu/Linux is the best platform out there, by finding a solution to the problem as flashy and whiz-bangy as the one on the Mac. How embarrassing, and I still prefer the wonderful obscurity of the command line. But for those of you who don't, know this, Baobab works fine and it looks prettier than GrandPerspective nyah, nyah, nyah.

Food for Thought


Food for Thought
Originally uploaded by gigib
This is my favorite restaurant in London. It is like going into a cozy family kitchen at dinnertime. You sit elbow to elbow with a dozen other people, and your meal is scooped from a casserole right onto your plate. Everything comes in generous helpings that mama would condone were she trying to fatten you up. The menu is short so no thinking, just eating. Typical choices are "the evening special", a soup, a quiche and a salad. The composition of these items change daily, and the ingredient outlook for the next couple days is posted inside the door. Enjoy breads, scones and casseroles that look as if they could have come out of your own kitchen (assuming you have talent and the Moosewood cookbook), and remember to save room for dessert. The Strawberry Banana Scrunch, a tasty trifle spooned up from a large casserole pan, is fantastic. Located at 31 Neal Street, Covent Garden; go there for cheap, good hippie comfort food. Mmm, just like me mum used to make.