MOTD http://zork.net/motd Message Of The Day en 60 Wed, 23 Mar 2005 22:53 GMT motd@zork.net PyBlosxom http://pyblosxom.sourceforge.net/ 1.3.2 2/13/2006 We Will Embrace The Fifth Generation sam/code/totally-prologing-this http://zork.net/motd/sam/code/totally-prologing-this.html
| ?- append(First,Second,[a,b,c,d,e,f,g]).

First = []
Second = [a,b,c,d,e,f,g] ? n
Action (; for next solution, a for all solutions, RET to stop) ? a

First = [a]
Second = [b,c,d,e,f,g]

First = [a,b]
Second = [c,d,e,f,g]

First = [a,b,c]
Second = [d,e,f,g]

First = [a,b,c,d]
Second = [e,f,g]

First = [a,b,c,d,e]
Second = [f,g]

First = [a,b,c,d,e,f]
Second = [g]

First = [a,b,c,d,e,f,g]
Second = []
]]>
/code Wed, 23 Mar 2005 22:53 GMT
If You Care sam/admin-spotting/real-time-hit-meter http://zork.net/motd/sam/admin-spotting/real-time-hit-meter.html

Real time apache hit meter. Displays number of hits per second on each line. Could probably be made more pretty with ANSI codes and whatnot. It only has one second of resolution which is a bit of a shame. Using something other than date could help that. I wrote this on a BSD system so GNU date may be better for this. Tuning the -10 passed to head varies the frequency of updating the output, and resolution a bit. And if you want to just check a part of the site or certain clients toss a grep (or some other selector) in between the while loop and the tail.

Note

Beware of I/O buffering. This is really not an accurate counter I've found because head can end up blocking more than is needed for its 10 lines of data.

tail -f access_log |
    (while true; do
        echo "`date +%s` `head -10 | wc -l` `date +%s`"
     done) |
    awk '$3 != $1 { print $2 / ($3 - $1) }'
]]>
/admin-spotting Sat, 19 Mar 2005 05:57 GMT
MySQL + PHP Still Not a Real Choice sam/code/of-course-php-is-dongz http://zork.net/motd/sam/code/of-course-php-is-dongz.html

Ok it's really super dumb that PHP pretty much handles MySQL connections to a database server one at a time. No seriously. There are some ways around this, but they are supremely lame, and in the function calls completely optional. So if a person ends up using code that someone else wrote, and that person didn't feel they needed to pass this completely optional argument on their database calls then person A's day can be made very hard. Especially if person A needs to use a couple different databases from one page.

http://us3.php.net/manual/en/function.mysql-select-db.php
]]>
/code Thu, 17 Mar 2005 00:31 GMT
When in doubt... sam/code/hacking-the-guhnome http://zork.net/motd/sam/code/hacking-the-guhnome.html

...hack it yourself.

Since Warty came out I have become a much more hardcore gui desktop user. I've hacked up quite a few Nautilus Scripts to make my life a little easier, but after "losing" a hard drive on my laptop I'm back to basic Nautilus. Now I've hit an annoying missing feature in it yet again.

Nautilus has this nice context menu that pops up for certain file types and allows to do nice things like add a bunch of files to Rhythmbox, make a tarball, or what have you. What they've never had was a way to make an image your desktop background. I know that this a silly thing to get all crazy about, but it really bugs me that it doesn't support this out of the box.

I used to have a script that would do this for me, but it is kinda annoying to have to right click, wait for the menu, then go to the Scripts menu, and wait for it to come up, and then finally click on "Make this my background." Also since it was attached to the scripts menu it could come up for any filetype which seems a little strange since you could ask the system to make an text file your background. It wouldn't do it of course it just seems like a bit of UI there.

So now here's what I want. I want a context menu for images that says "Change Desktop Background to image..." And then does it. And I would prefer to learn as little as possible about the guts of Gnome and Nautilus in the process. And I don't want to have to do it in C, I'd rather do it in python.

So I whip out google and start to figure out how to do this "simple" task. There seems to be a few python-bonobo tutorials out there, mostly working with making panel applets. Bonobo adds this big maze to some of the Gnome stuff. There are a few tools to manipulate it, but it mostly works like a scary black box. And doesn't appear to like making any log messages at all.

So I start taking apart some apps that use the interface namely file-roller. The nautilus source package also has a pdf that contains some documentation on how to build some interfaces. So I start to learn about bonobo. For instance, did you know that bonobo can be used as a primitive medieval torture device? It's true. Also it has something to do with CORBA which accounts for it's rampant insanity. So I try randomly typing strings into vi and started to get some results. The bonobo query whatnot was telling me that yes it knew about my crazy extension, but nautilus still was not using it.

Why nautilus? Why do you hate me so?

Follows is some of the notes that I was taking:

Try some tricks. ltracing nautilus == crash.

Sure would be nice to find out how nautilus pulls these menu items out
of it's ass.  Apparently it doesn't use the bonobo activation the way we think
it should.  libeel.  More nautilus guts.  Also some eel guts.  Remember to wash
hands.

So in the end it looks like someone decided to extricate all of the bonobo bits out of nautilus. Great. No more bonobo. But now there is no easy python way (at least from what I see) to screw around with nautilus.

I guess sometimes when in doubt just keep doing it the lame crappy way. Ok, back to hacking pgscsh. Hacking the guhnome is too hard today.

]]>
/code Mon, 14 Mar 2005 05:20 GMT
Cluestick Please sam/admin-spotting/stupid-fucks-part-1 http://zork.net/motd/sam/admin-spotting/stupid-fucks-part-1.html

So why in the hell do people feel the need to put our browsers through redirect hell to download a tarball? Listen up fuckers, I don't want to download your crap ass SERVER software on my WORKSTATION. I need it on the SERVER.

GAR GAR GAR.

]]>
/admin-spotting Mon, 28 Feb 2005 05:51 GMT
Cool Python Idiom sam/code/cool-python-idiom http://zork.net/motd/sam/code/cool-python-idiom.html

This is a handy thing if you are playing with big stuff in the python repl.

import os
less = os.popen('less', 'w')
less.write( ... bunch of data written out here ...)
less.close()

The great thing is also that you can pass less anywhere that you have a filehandle that you're writing to.

Beaujolais!

What would be really great is if you could make a file object that would invoke less if you have more than $LINES of output in a go. Then you could do:

sys.stdout = less_stdout()

or somesuch.

That would be totally bitchin.

]]>
/code Fri, 28 Jan 2005 08:59 GMT
God Help Us All sam/i-still-hate-php http://zork.net/motd/sam/i-still-hate-php.html

January Headline: PHP awarded programming language of 2004

The TIOBE Programming Community index gives an indication of the popularity of programming languages. The index is updated once a month. The ratings are based on the world-wide availability of skilled engineers, courses and third party vendors. The popular search engines Google, MSN, and Yahoo! are used to calculate the ratings. Observe that the TPC index is not about the best programming language or the language in which most lines of code have been written.

http://www.tiobe.com/tpci.htm

]]>
Sun, 09 Jan 2005 09:04 GMT
They ran out of Dutch Crunch sam/lees-deli-blt/20050106 http://zork.net/motd/sam/lees-deli-blt/20050106.html

There was no dutch crunch bread. So I had to get a french roll. It was quite tasty. I think I may need to retire the dutch crunch selection for a while.

The french roll interacted well with the swiss cheese. All and all goodness.

]]>
/lees-deli-blt Thu, 06 Jan 2005 22:16 GMT
Important Google Information Pertaining to LEE'S DELI sam/lees-deli-blt/20041220 http://zork.net/motd/sam/lees-deli-blt/20041220.html

We have technology now. How great.

http://www.google.com/local?hl=en&lr=&sa=G&q=Lee%27s+Deli&near=San+Francisco,+CA&oi=localr

]]>
/lees-deli-blt Mon, 20 Dec 2004 22:41 GMT
Today's Adventure sam/lees-deli-blt/20040928 http://zork.net/motd/sam/lees-deli-blt/20040928.html

I set out at lunch today to go somewhere that wasn't Lee's. For some reason I just didn't want it. I wanted something pizza-y. I headed out to the Crocker Galleria on Post (or Sutter depending on which direction you are coming from.) I looked at the San Francisco Soup Company (another big Downtown SF chain) and a few other places. Nothing looked appealing. Walked up Kearny towards North Beach, passed the International Food Court on Bush and Kearny to find a Lee's.

This Lee's had a nice dining room that looked into Belden Alley. Most of the Lee's are just Delis, with no dining space. This one also has a little salad bar.

I got my usual, and noticed that the price wasn't quite the same as the Lee's on Market. This isn't unusual as the Lee's on Market the price fluctuates depending on who makes the sandwich and what time of day it is. After getting my sandwich I also noticed that on the cash register there was a sticker stating that they round all prices to the nearest nickle. No pennies at Lee's. Horray for the abolishment of the penny.

I ended up with pizza for dinner. All and all not bad.

]]>
/lees-deli-blt Wed, 29 Sep 2004 04:16 GMT
Tacos sam/lees-deli-blt/20040923 http://zork.net/motd/sam/lees-deli-blt/20040923.html

Today no Lee's. Instead went to the International Food Court thing in the basement at Bush and Belden Place and got tacos. Need to get some filipino food there one day.

]]>
/lees-deli-blt Thu, 23 Sep 2004 20:47 GMT
Different Lee's sam/lees-deli-blt/20040922 http://zork.net/motd/sam/lees-deli-blt/20040922.html

I went to the Lee's on New Montgomery today. Much bigger than the one on Market that usually go to. They have a salad bar, chinese food, and some burrito thing going on.

I got my usual. No melted cheese today, but I think they either use better Mayo or more mayo, or some better cheese. Quite tasty.

]]>
/lees-deli-blt Wed, 22 Sep 2004 20:06 GMT
Really Bloggy sam/lees-deli-blt/links http://zork.net/motd/sam/lees-deli-blt/links.html

It has come to my attention that blogs should have links. So, um here are some:

http://www.sfstation.com/restaurants/lees

http://google.com/search?q=bacon+lettuce+tomato

]]>
/lees-deli-blt Tue, 21 Sep 2004 20:52 GMT
Today's Sammich sam/lees-deli-blt/20040921 http://zork.net/motd/sam/lees-deli-blt/20040921.html

They have topped themselves today at Lee's. Apparently by the time I got in to get my sandwich the Bacon had cooled down. So they heated it up in the microwave. When I asked for my slice of cheese on the sandwich they put the cheese on the BACON IN THE MICROWAVE.

MELTED CHEESE!

This is probably the best so far. An almost hot BLT with melted Cheddar! Also discovered that Lee's has Orangina. Which is probably the best Orange drink in existence. Unfortunately I got the last one in the cooler so hopefully they get restocked daily.

]]>
/lees-deli-blt Tue, 21 Sep 2004 20:46 GMT
NEW BLOG sam/lees-deli-blt/intro http://zork.net/motd/sam/lees-deli-blt/intro.html

So I moved to SF in January. There were many things I didn't know about. Like where to get good lunches. After I got a job I found via a coworker Lee's Deli. Lee's Deli is great and cheap. There are several in downtown SF making it very convenient.

On their menu they had a BLT for like $3. Whatta lunch deal. They put tons of Bacon on it. It's like super bacon. So at first I would only get it on plain wheat bread. It was a super bacon sandwich, but with the wheat bread it would get mushy.

Then I found out about their other breads. I was on a path of upgrading to the Ultimate Bacon Lettuce Tomato Sammich.

This journal exists to log my journey to BLT nirvana.

Up to this point:

  • Replaced wheat bread with Dutch Crunch roll
  • Added two slices of swiss
  • Removed a slice of swiss, didn't change sandwich much and saves 5 cents
  • Changed swiss to cheddar.
]]>
/lees-deli-blt Tue, 21 Sep 2004 20:46 GMT
THINGS THAT HAPPEN sam/code/python-abuse-1 http://zork.net/motd/sam/code/python-abuse-1.html
import UserDict,os

class WriteFileCacheDict (UserDict.UserDict):
    def __getitem__ (self, key):
        if not self.data.has_key(key):
            self.data[key] = open (key, 'w+')
        return self.data[key]

class MagicalFileDict (WriteFileCacheDict):
    def __getitem__ (self, key):
        if not self.data.has_key(key):
            d = os.path.dirname(key)
            if not os.path.isdir(d):
                os.makedirs(d)
        return WriteFileCacheDict.__getitem__(self, key)
]]>
/code Sat, 18 Sep 2004 01:30 GMT
[CHU SIGHTING] Wed Jun 16, 2004 sam/chu-sightings/Wed_Jun_16,_2004_ http://zork.net/motd/sam/chu-sightings/Wed_Jun_16,_2004_.html
 WHEN: Wed Jun 16, 2004 -
WHERE: Post and Market
NOTES: A guy I work with and I were out having lunch and caught
       Frank checking out the PETA Bikini girls wrestling in tofu.
       Unfortunately the pictures that he got were of Frank's back.

       http://www.mojado.com/misc/photos/view_photo.php?set_albumName=SF-17-Jun-2004&id=Girls_tofu1_040617
       http://www.mojado.com/misc/photos/view_photo.php?set_albumName=SF-17-Jun-2004&id=Girls_tofu2_040617
]]>
/chu-sightings Sat, 26 Jun 2004 00:17 GMT
[CHU SIGHTING] A Couple Weeks Ago sam/chu-sightings/A_Couple_Weeks_Ago_-_Afternoon http://zork.net/motd/sam/chu-sightings/A_Couple_Weeks_Ago_-_Afternoon.html

     WHEN: A Couple Weeks Ago - Afternoon
    WHERE: Market and Geary
    IMAGE: http://www.dasbistro.com/~sam/photo-gallery/frank-chu/dscn0793.html
    NOTES: Frank was hanging out with the guys selling cherries on the
           corner

 
]]>
/chu-sightings Wed, 19 May 2004 21:17 GMT
Slow Down There Buddy sam/admin-spotting/slothly http://zork.net/motd/sam/admin-spotting/slothly.html

This chunk of code allows you to add a little artificial slow down to your bash scripts. Add it to the top of the shell script and watch ... everything ... pass ... by ... real ... slow.

Especially useful with set -x.

sleep_some () { sleep 1; }
trap sleep_some DEBUG
]]>
/admin-spotting Mon, 26 Apr 2004 18:16 GMT
Tales from the Vault sam/admin-spotting/tricksy http://zork.net/motd/sam/admin-spotting/tricksy.html

So this is probably a no-no to someone, but it is an intriguing trick. At the beginning of your shell scripts try this on:

cat $1 |
    ... <rest of code>

So let's say you want a program to take input from stdin or from the command line argument. Viola! There you go. If someone does specify an argument then it waits for stdin. Or if you do specify an argument it just handles it. I can imagine a few reasons why it probably isn't good for production code. But damn I like it.

]]>
/admin-spotting Mon, 12 Apr 2004 08:25 GMT
Frank Chu Sightings sam/mail/mh-addiction_part-1 http://zork.net/motd/sam/mail/mh-addiction_part-1.html

I like using MH even though some "features" of it are weird and/or somewhat tarded. It's just crazy, and I've really started getting into it. Anyway several Frank Chu sightings this week prompted me to write a script that allows me to post messages to the <a href="http://tastytronic.net/cgi-bin/mailman/listinfo/rocket-society">Rocket Society</a> quickly.

<a href="http://zork.net/~sam/chu-sighting">chu-sighting</a>

]]>
/mail Sat, 27 Mar 2004 01:32 GMT
teez sam/admin-spotting/tidbit http://zork.net/motd/sam/admin-spotting/tidbit.html

tee with compression:

#!/bin/bash

tee >( gzip -c9 > $1 )
]]>
/admin-spotting Wed, 24 Mar 2004 17:59 GMT
Hooray for close-enough sam/admin-spotting/close-enough http://zork.net/motd/sam/admin-spotting/close-enough.html Makes typos work for you. Caution: May cause major system damage if used erroneously. ]]> /admin-spotting Tue, 23 Mar 2004 18:31 GMT OMG!!!!! sam/DON_FUCKIN_KNUTH http://zork.net/motd/sam/DON_FUCKIN_KNUTH.html

I met DON MOTHERFUCKING KNUTH...

OMFG!!!!

]]>
Sat, 21 Feb 2004 09:30 GMT
Don't get me wrong... sam/books/bad-books http://zork.net/motd/sam/books/bad-books.html

I <i>like</i> New Riders Python Essential Reference. It has helped me out many times, especially when I am writing python scripts in a notepad on the train. But the Second Edition copy has a totally hosed table of contents. The pages are all off by 1-2 pages. It appears that the index is correct which is slightly helpful.

Example: getopt functions according to the TOC should be on page 164. In reality they're on 166.

pubsmack!

]]>
/books Thu, 05 Feb 2004 08:04 GMT
Reinvention is good for Innovation sam/gis/gis-manifesto http://zork.net/motd/sam/gis/gis-manifesto.html

So after talking to Nick and working discovering more about GIS, cartography, and geography in general I have come to the conclusion that I need to spend the next several years working on a GIS system for Hackers.

So read my <a href="http://www.dasbistro.com/~sam/essays/a-gis-for-hackers.txt">notes/manifesto</a>.

]]>
/gis Tue, 03 Feb 2004 04:06 GMT
More Teh Lunix sam/admin-spotting/hooray-for-hidden-docs http://zork.net/motd/sam/admin-spotting/hooray-for-hidden-docs.html

While attempting to hack up a proxy arp daemon thing that would cook my emergency bacon I got frustrated. I was attempting to transcend the ethernet header and examine the arp packet. For some strange reason the only illumination to be gathered from the arp packet was that it was full of NULL bytes. Extreme frustration set in, at which time I thought to myself, "Screw this pony! This thing has to work without stupid userspace tools!"

A more subtle crafting of google search terms lead me to the astonishing revelation: Linux won't answer ARP for an IP on an interface if the routing table says that the packet should be routed back out of that interface! Well of course not! If it did that you could blackhole all sorts of network traffic without even really trying. The solution of course is to make it think that it is routing it elsewhere (in my case the loopback device), and then the iptables can step in and do the right thing.

So the lesson learned here is: if you do strange voodoo with your packets you need to think about non-voodoo things that the OS may be trying to save you from.

]]>
/admin-spotting Wed, 28 Jan 2004 06:18 GMT
Teh Lunix sam/admin-spotting/so-broken http://zork.net/motd/sam/admin-spotting/so-broken.html Proxy Arp appears to not be working for me (2.4.18 and 2.4.24). I'm pretty sure that something is wrong, but I seem to be at a loss for finding actual useful documentation on actually debugging what is wrong. And now I'm about to hotwire something up in scapy or some crazy hax0r tools just to get it to work. GAR GAR GAR!!!While doing this it occurs to me that I really should put the HURD on this box soon. ]]> /admin-spotting Fri, 23 Jan 2004 09:26 GMT Travels with Crackmonkey sam/transit-fu/model-transit http://zork.net/motd/sam/transit-fu/model-transit.html

The Caltrain pub crawl was a success. Part of the conversations that I had with Nick revolved around building a model railroad (HO Scale) public transit doohicky along the lines of San Francisco bay area, something that is more like a big Muni + what would have happend if the Key System lived on. There would probably be minimal BART influence.

Some loose googling today has yielded these results:

I've found some similar type projects from folks on the east coast. One is modeling <a href="http://www.trainweb.org/asamtrak911/mbta.html">Boston</a>, and the other is <a href="http://home.earthlink.net/~feigenbaums/modelrr_photos.htm">Philly/New York hybrid</a> deal.

]]>
/transit-fu Wed, 21 Jan 2004 01:57 GMT
sam/gis/reinvention http://zork.net/motd/sam/gis/reinvention.html

I have devtoed some brainpower off and on for the past few days to reinventing the problem domain of GIS. In doing this pondering I have decide to stick it out with <a href="http://grass.ibiblio.org/">GRASS</a> which has some problems, but for the most part works.

Now to take apart how it does things and make them super. Step 1: v.export.svg and scheme bindings!

]]>
/gis Fri, 16 Jan 2004 02:54 GMT
Pseudo-<a href="/motd/mrbad">Mister Bad</a> Fan Watch sam/the_burning_man http://zork.net/motd/sam/the_burning_man.html We're at Burning Man!!! Yay! Yay!

What day is it again?

Also... Spock Science Monitors have been published. But they probably won't be posted until next week. ]]>
Sat, 30 Aug 2003 03:41 GMT
Reticule sam/schemey/gmane http://zork.net/motd/sam/schemey/gmane.html

<a href="http://www.gmane.org">Gmane</a> is powered by the <a href="http://reticule.gmane.org/">Common Lisp</a>.

]]>
/schemey Tue, 15 Jul 2003 07:01 GMT
Mail is Funny sam/mailx http://zork.net/motd/sam/mailx.html

Evan, try setting the environment variable REPLYTO. It's listed in the mailx man page.

]]>
Mon, 19 May 2003 08:48 GMT
Temperature sam/no-hair http://zork.net/motd/sam/no-hair.html

My internal heating unit is broken. Mister Bad shaved my head. I told people at the lnx-bbc party that that was why my head was shaved. Because Mister Bad did it. People in San Francisco love Mister Bad. They were all "You saw Mister Bad!!!" Yes I did.

I keep sweating because my body is trying to compensate for the loss of heat retaining hair on my head. I think I may get a tuke to wear while I sleep so that my head doesn't freeze at night.

]]>
Mon, 19 May 2003 08:46 GMT
Guile? You Gotta Be Kidding. sam/schemey/guile http://zork.net/motd/sam/schemey/guile.html

I will respect <a href="http://www.glug.org/">Guile</a>. But that doesn't mean I have to like it.

]]>
/schemey Fri, 16 May 2003 21:22 GMT
WAH WAH PEDAL sam/f00lzor http://zork.net/motd/sam/f00lzor.html

It's April Fool's!

It's Mailman Day!

Two Great Tastes that Taste Great Together!

]]>
Tue, 01 Apr 2003 17:20 GMT
All this scheme stuff is making me excited! sam/schemey/scheme-tastic http://zork.net/motd/sam/schemey/scheme-tastic.html

I'm working on spawk, a scheme-awk hybrid. And for the last couple days I've been writing <a href="http://librep.sf.net">rep</a> code to use in sawfish.

Woo scheme. I'm taking apart these python programs I have and am now writing them in scheme.

]]>
/schemey Wed, 26 Feb 2003 21:06 GMT