Monday, April 13, 2009

so, i bought this book...


so, i bought this book...


hey, what's this?


er...

Friday, February 27, 2009

in case you need it: finding postgresql tables with a specific column

I have a couple of related database with a bunch of tables that all have "username" columns (actual varchars, not foreign keys). Two or three times a year, I end up having to change that for a user (usernames are email addresses, and users change their email accounts, or switch jobs or whatever). Previously I'd relied on a bunch of update statements that blindly attempted to change that field in all tables, but I finally decided today to write a script to automate that task.

Finding all the tables with username as a column:


select c.relname from pg_class c
join pg_attribute a on (c.oid = a.attrelid)
join pg_roles r2 on (c.relowner = r2.oid)
where a.attname = 'username' and c.relkind = 'r' and r2.rolname = 'pkf';

Time to write the script (with error checking, tests, etc): about an hour. Time I usually spend changing usernames without the script: about 10 minutes a year. So, a net win, or net loss?

Wednesday, February 11, 2009

I, Nezahualcoyotl, ask this:

Is it true one really lives on the earth?
Not forever on earth, only a little while here.
Though it be jade it falls apart,
though it be gold it wears away,
though it be quetzal plumage it is torn asunder.
Not forever on earth, only a little while here.

I comprehend the secret, the hidden: O my lords!
Thus we are,
we are mortal,
men through and through,
we all will have to go away,
we all will have to die on earth.

Like a painting, we will be erased.
Like a flower, we will dry up here on earth.
Like plumed vestments of the precious bird,
that precious bird with the agile neck,
we will come to an end...

Think on this, my lords,
eagles and ocelots,
though you be of jade,
though you be of gold,
you also will go there,
to the place of the fleshless.
We will have to disappear,
no one can remain.

qotd

Painting is not done to decorate apartments. It is an instrument of war for attack and defense against the enemy.

— Pablo Picasso

Wednesday, February 04, 2009

the coming anarchy

so, i was using google spreadsheet the other day...

So, I was using the Google Spreadsheet the other day, and entered
=today()
in a few cells.

The next day, the cells had the next day's date. Doh!
This is what I get for ignoring spreadsheets for a couple of decades.

Wednesday, January 28, 2009

funny spam header

From: free@brain.net.pk         
Date: Wed, 28 Jan 2009 18:19:45 +0500 (PKT)
Subject: Brain Net - Internet is FREE Now.
To: info@b.org.pk
DomainKey-Status: no signature
X-Mailer: @(#) mailsend v1.06 (Unix)
X-Copyright: GNU GPL. It is illegal to use this software for Spamming

[-- Attachment #1: free.jpg --]
[-- Type: image/jpg, Encoding: base64, Size: 489K --]

[-- image/jpg is unsupported (use 'v' to view this part) --]

Unfortunately for them, I was thinking earlier today about making a page of local companies that have spammed me. I don't know when (if!) I'll get around to doing that, but here's a partial list:

Friday, January 23, 2009

oh dear

Let us begin with Urdu which, apart from being the National and Official language of Pakistan, is also the most widely used and spoken Arabic script language in the world after Arabic itself. While discussing the development of Urdu Computing Standards, the leading experts in the field conceded that:

Different authors have quoted different number of characters in Urdu alphabet (e.g. even the elementary books for children do not agree on the same alphabet. Kifayat (1993), Siraj (1999), PTBB [Punjab Text Book Board] (2000), BUQ (1999) and KUQ(1999) have 36, 51, 53, 47, and 37 characters respectively...) ... As no general agreement was available, the standardization] committees agreed to consider the alphabet used by the National Language Authority (NLA), which contains 57 characters...

Wednesday, January 21, 2009

as i unfolded yet another staple, i wondered

People throw away a lot of staples all the time — thousands every day, in every city, all over the world. I think they should be recycled, but how? What would work for you, in your community/office/etc?

Googling for recycle staple shows that I'm not the only one who's wondered about this.

Monday, January 19, 2009

stack traces

A stack trace in Zope 2.x looks like


Traceback (innermost last):
Module ZPublisher.Publish, line 115, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 41, in call_object
Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
- __traceback_info__: ((<Folder at /virtualroot/pkf/indexes>,), {}, None)
Module /home/pkf/pkf-z29/Extensions/valuation.py, line 107, in uploadvaluationentries
Module psycopg2.extras, line 85, in execute
IntegrityError: duplicate key violates unique constraint "valuationweightage_indexname_key"

A stack trace in Pylons 0.9.7 (pre-release) looks like


URL: http://127.0.0.1:9200/contact/sent
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/WebError-0.10.1-py2.5.egg/weberror/errormiddleware.py', line 162 in __call__
app_iter = self.application(environ, sr_checker)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Beaker-1.1.3-py2.5.egg/beaker/middleware.py', line 81 in __call__
return self.app(environ, start_response)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Beaker-1.1.3-py2.5.egg/beaker/middleware.py', line 159 in __call__
return self.wrap_app(environ, session_start_response)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Routes-1.10.1-py2.5.egg/routes/middleware.py', line 118 in __call__
response = self.app(environ, start_response)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Pylons-0.9.7rc4-py2.5.egg/pylons/wsgiapp.py', line 117 in __call__
response = self.dispatch(controller, environ, start_response)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Pylons-0.9.7rc4-py2.5.egg/pylons/wsgiapp.py', line 316 in dispatch
return controller(environ, start_response)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/ifis-0.1dev-py2.5.egg/ifis/lib/base.py', line 16 in __call__
return WSGIController.__call__(self, environ, start_response)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 204 in __call__
response = self._dispatch_call()
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 159 in _dispatch_call
response = self._inspect_call(func)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 95 in _inspect_call
result = self._perform_call(func, args)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Pylons-0.9.7rc4-py2.5.egg/pylons/controllers/core.py', line 58 in _perform_call
return func(**args)
File '<string>', line 2 in sent
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/Pylons-0.9.7rc4-py2.5.egg/pylons/decorators/__init__.py', line 209 in wrapper
return func(self, *args, **kwargs)
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/ifis-0.1dev-py2.5.egg/ifis/controllers/contact.py', line 48 in sent
self._emailfeedback()
File '/home/pkf/pylonsdevenv/lib/python2.5/site-packages/ifis-0.1dev-py2.5.egg/ifis/controllers/contact.py', line 100 in _emailfeedback
server.sendmail('ifis.pk', [request.params.get('cemail')], mail.as_string())
File '/usr/local/lib/python2.5/smtplib.py', line 707 in sendmail
raise SMTPDataError(code, resp)
SMTPDataError: (451, 'qq internal bug (#4.3.0)')

Thursday, January 15, 2009

so, i have this idea.

Take jabber, convert the wire protocol from xml to protocol buffers.

Wednesday, January 07, 2009

c is for cookie


<_ja> http://www.cs.unm.edu/~fastos/05meeting/PLAN9NOTDEADYET.pdf
<_ja> yeah right
<_ja> when you have to declare something isnt dead, isnt it kinda dead
<self> james, you can run 9vx today!
<_ja> i was actually considering it
<_ja> any good?
<self> works for me.
<_ja> cool
<_ja> i shall try it!
<_ja> and follow your noble trailblazing example good sir!
<self> if you have mercurial installed, i recommend grabbing vx32 instead
<self> hg clone http://hg.pdos.csail.mit.edu/hg/vx32/
<self> build 9vx inside that
<self> then you need http://swtch.com/9vx/9vx.tgz
<self> oh, yeah
<self> and shove this in your ~/.Xdefaults:
<self> 9vx.geometry: 1024x700
<self> or whatever
<self> you don't need a separate drive, or partition or whatever.
<self> the good news is (but don't tell anyone), you can write your code in emacs outside 9vx
<_ja> hot!
<self> the bad news is, you're still writing code in c. a variant of c, but c nonetheless.
<_ja> oh god not C
<_ja> do i have to
<_ja> dealbreaker baby!
<scottr> stop whining. it could be perl. or php.
<_ja> k ok i remember now i kinda like C

Tuesday, January 06, 2009

the good news is, the stock markets are up

For three days now, the stock market has closed up. It's likely that this trend will continue for the near future (barring a war or something catastrophic like that).

The bad news is, I don't have any money to invest right now. Worldcall, at Rs 2.99 last week, now trading at Rs 5.08. TRG down to Rs 1.30 a couple of weeks ago, now at Rs 3.05. I coulda made a killing!

Saturday, January 03, 2009

stargate: atlantis

“Vegas” is a fun episode. A pity there's only one more before the season (series!) ends.

Thursday, November 27, 2008

facebook pages you might be interested in (then again...)

beachball

I wish for a cute iPhone app that has beachballs. How can it be an OS X app without random beachballs? Don't they let you do

[NSSchedule atRandomInterval: [[NSBeachBall alloc] init]];?

Wednesday, November 12, 2008

qmail on facebook

The qmail page on Facebook is http://www.facebook.com/pages/qmail/50259341137.

Tuesday, October 21, 2008

slumming

<fn[19:01]> and, lost power again.
<ChrisSmol[06:01]> welcome to zimbabwe

Monday, October 06, 2008

children

Lotfi Zadeh has a son.

Thursday, September 25, 2008

quote of the day

When I read that part in the script where it said, "Luke, I am your father", I thought, "He's lying. I have to see how they carry this lie out."James Earl Jones