MOTD

Message Of The Day

Wed, 23 Mar 2005

22:53 [zork(~/code)] cat totally-prologing-this.txt

We Will Embrace The Fifth Generation

| ?- 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 = []

Sat, 19 Mar 2005

05:57 [zork(~/admin-spotting)] cat real-time-hit-meter.txt

If You Care

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) }'

Thu, 17 Mar 2005

00:31 [zork(~/code)] cat of-course-php-is-dongz.txt

MySQL + PHP Still Not a Real Choice

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

Mon, 14 Mar 2005

05:20 [zork(~/code)] cat hacking-the-guhnome.txt

When in doubt...

...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.

Mon, 28 Feb 2005

05:51 [zork(~/admin-spotting)] cat stupid-fucks-part-1.txt

Cluestick Please

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.

Fri, 28 Jan 2005

08:59 [zork(~/code)] cat cool-python-idiom.txt

Cool Python Idiom

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.

Sun, 09 Jan 2005

09:04 [zork(~)] cat i-still-hate-php.txt

God Help Us All

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

Thu, 06 Jan 2005

22:16 [zork(~/lees-deli-blt)] cat 20050106.txt

They ran out of Dutch Crunch

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.

Mon, 20 Dec 2004

22:41 [zork(~/lees-deli-blt)] cat 20041220.txt

Important Google Information Pertaining to LEE'S DELI

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

Wed, 29 Sep 2004

05:16 [zork(~/lees-deli-blt)] cat 20040928.txt

Today's Adventure

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.

Thu, 23 Sep 2004

21:47 [zork(~/lees-deli-blt)] cat 20040923.txt

Tacos

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.

Wed, 22 Sep 2004

21:06 [zork(~/lees-deli-blt)] cat 20040922.txt

Different Lee's

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.

Tue, 21 Sep 2004

21:52 [zork(~/lees-deli-blt)] cat links.txt

Really Bloggy

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

21:46 [zork(~/lees-deli-blt)] cat 20040921.txt

Today's Sammich

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.

21:46 [zork(~/lees-deli-blt)] cat intro.txt

NEW BLOG

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.

Sat, 18 Sep 2004

02:30 [zork(~/code)] cat python-abuse-1.txt

THINGS THAT HAPPEN

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)

Sat, 26 Jun 2004

01:17 [zork(~/chu-sightings)] cat Wed_Jun_16,_2004_.txt

[CHU SIGHTING] Wed Jun 16, 2004

 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

Wed, 19 May 2004

22:17 [zork(~/chu-sightings)] cat A_Couple_Weeks_Ago_-_Afternoon.txt

[CHU SIGHTING] A Couple Weeks Ago



     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

 

Mon, 26 Apr 2004

19:16 [zork(~/admin-spotting)] cat slothly.txt

Slow Down There Buddy

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

Mon, 12 Apr 2004

09:25 [zork(~/admin-spotting)] cat tricksy.txt

Tales from the Vault

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.

Sat, 27 Mar 2004

01:32 [zork(~/mail)] cat mh-addiction_part-1.txt

Frank Chu Sightings

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>

Wed, 24 Mar 2004

17:59 [zork(~/admin-spotting)] cat tidbit.txt

teez

tee with compression:

#!/bin/bash

tee >( gzip -c9 > $1 )

Tue, 23 Mar 2004

18:31 [zork(~/admin-spotting)] cat close-enough.txt

Hooray for close-enough

Makes typos work for you. Caution: May cause major system damage if used erroneously.

Sat, 21 Feb 2004

09:30 [zork(~)] cat DON_FUCKIN_KNUTH.txt

OMG!!!!!

I met DON MOTHERFUCKING KNUTH...

OMFG!!!!

Thu, 05 Feb 2004

08:04 [zork(~/books)] cat bad-books.txt

Don't get me wrong...

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!

Tue, 03 Feb 2004

04:06 [zork(~/gis)] cat gis-manifesto.txt

Reinvention is good for Innovation

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>.

Wed, 28 Jan 2004

06:18 [zork(~/admin-spotting)] cat hooray-for-hidden-docs.txt

More Teh Lunix

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.

Fri, 23 Jan 2004

09:26 [zork(~/admin-spotting)] cat so-broken.txt

Teh Lunix

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.

Wed, 21 Jan 2004

01:57 [zork(~/transit-fu)] cat model-transit.txt

Travels with Crackmonkey

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.

Fri, 16 Jan 2004

02:54 [zork(~/gis)] cat reinvention.txt

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!

Sat, 30 Aug 2003

04:41 [zork(~)] cat the_burning_man.txt

Pseudo-Mister Bad Fan Watch

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.

Tue, 15 Jul 2003

08:01 [zork(~/schemey)] cat gmane.txt

Reticule

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

Mon, 19 May 2003

09:48 [zork(~)] cat mailx.txt

Mail is Funny

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

09:46 [zork(~)] cat no-hair.txt

Temperature

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.

Fri, 16 May 2003

22:22 [zork(~/schemey)] cat guile.txt

Guile? You Gotta Be Kidding.

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

Tue, 01 Apr 2003

18:20 [zork(~)] cat f00lzor.txt

WAH WAH PEDAL

It's April Fool's!

It's Mailman Day!

Two Great Tastes that Taste Great Together!

Wed, 26 Feb 2003

21:06 [zork(~/schemey)] cat scheme-tastic.txt

All this scheme stuff is making me excited!

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.


[zork(~)] cal
[zork(~)] tree
[zork(~)] syndicate.py
[zork(~)] cat README