oops command lives



years ago i saw my dad working in a terminal and i could have sworn i typed "oops " when he made a typo and it worked: the command was fixed and rerun, he didn't need to retype the whole thing. i always wanted the oops command.

however, it didn't exist, or at least as i knew it. so i wrote a portable version of it (it seems it exists in zsh, a shell i just don't use). the python part of it is really simple, just a levenshtein distance calculator and a replacement engine. you need to create a command alias for it however:

ksh, sh, bash:
$ alias oops='history>/tmp/oops_history && ~/bin/oops.py'
csh and derivatives:
% alias oops 'history > /tmp/oops_history && ~/bin/oops.py'
here's a brief example of it in action:
$ emacss ~/bin/oops.py
ksh: emacss: not found
$ oops emacs
[ emacs opens and voila, working ... ]
i make a lot of typos and rather than cutting, pasting, fixing the line this makes it easier. some bugs and limitations:
  • i need to make it use the damerau distance, which is better for spelling errors)
  • not extensively field tested at all
  • it doesn't leave a corrected mark in your history file
  • it doesn't work for shell built-ins (e.g. cd)
let me know if you're interested in playing around with it.

     [link]     Monday, Nov 17, 2008 @ 11:27am

      |


translate button



i work with a lot of foreign language websites, most in languages i do not read. to help me with that i often use google translate. but, i got sick of copying and pasting URLs or text, so i built this translate button for firefox.

it works like this: when you're on a page and you want to translate it, surf to the "translate" bookmark (i've located mine in the bookmark toolbar folder in ffox). poof, automagically translated into english. the magic is that the bookmark is javascript that will construct the proper URL for your current page as a target of google translate, and then surf you there. voila.

make a "translate" bookmark and make this the "location" in its properties. now you, too, can have a translate button.
javascript:var h = escape(location.href); 
           newurl = 'http://translate.google.com/translate?u=' + h + '&hl=en&ie=UTF-8&sl=*&tl=en';
           document.write(newurl);
           window.location = newurl;
paste that code in. simple as that. if you need to change the target language you can change "tl=en" to another laguage (e.g. "es" or "fr"). the source language is automatically determined by google translate (see "sl=*").

     [link]     Sunday, Oct 26, 2008 @ 07:16pm

      |


csv2xml.py



whipped this up for someone earlier today:
#!/usr/bin/env python

import cgi, csv, sys, cElementTree

reader = csv.reader(open(sys.argv[1], "r"), quoting=csv.QUOTE_NONE) lineno = -1 root = cElementTree.Element('document', {'name': sys.argv[1], 'generator': 'csv2xml.py'}) for line in reader: lineno += 1 if lineno == 0: fields = line continue elem = cElementTree.SubElement(root, 'line', {'lineno': str(lineno)}) for i, field in enumerate(fields): subelem = cElementTree.Element(cgi.escape(field.replace(' ', '_').replace('&', 'and'))) subelem.text = cgi.escape(line[i]) elem.append(subelem)

cElementTree.dump(root)


similar to http://csv2xml.sourceforge.net/.

     [link]     Friday, Oct 24, 2008 @ 03:05pm

      |


eating, playing, week of sep 29





little dom's been feverin' lately, but he's slowly getting better.

for the past year and a half i've been working my way through cookbooks and stuff, learning new recipes and techniques, rarely repeating myself. it's a challenge, and sometimes beth wants an old favorite that fell way back, but overall we've found a few gems. here's a couple we made this week: we eat well, and it's a lot of fun to cook.

been getting into wooden toys for dominic. i can't bring myself to spend $56 a set on wooden blocks, so i've been investigating making my own. stay tuned ...

does dominic need his own homepage on kidmondo? it may simplify stuff for his relatives to keep track of him.

also been thinking about finally painting inside the house. i wonder if we could pull off peacock blue cabinets.

     [link]     Friday, Oct 03, 2008 @ 09:24am

      |


shadow on studio 360



found this online while digging for a story i heard recently.



shadow, many years ago, was an awakening for me to a resurgent hip hop and way better DJs than when i was a kid. i still enjoy his work. he's on tour this summer with cut chemist in their third installment of an all 45rpm scratchfest, the hard sell. i've heard excerpts. quite impressive, yet again.

     [link]     Wednesday, Sep 24, 2008 @ 10:43am

      |


food ideas for week of sep 22 2008



via various blogs, some ideas of things i may make this coming week. rather than putting them in the wiki and hoping i remember, here they are:

i also need to capture my herbs from my garden box.

as a quick report, Sauteed Chicken with Olives, Capers and Roasted Lemons was not so good. the acid of the lemons and the brine of the capers and olives did not make for an appetizing flavor. next time i'll skip the olives and capers. however, Chicken with Piquillos, aka pollo casero, was a hit. one small serving left at home.

     [link]     Friday, Sep 19, 2008 @ 03:32pm

      |


organic chemistry



pre-meds again complaining that they shouldn't be subjected to a year of rigorous organic chemistry because it's hard.

http://blogs.wsj.com/health/2008/07/16/do-pre-meds-really-need-that-year-of-organic-chemistry/

i have always, and continue to do so, advocated for a full year of o chem for pre-meds prior to biochemistry.

     [link]     Friday, Sep 19, 2008 @ 01:12pm

      |


yum yum bento





flickr photo by Sakurako Kitsa.

delicious looking bento boxes on flickr. lots of talented people out there eating delicious food.

     [link]     Sunday, Sep 14, 2008 @ 02:10pm

      |