extends all the way across to the right, so we just
* highlight the table */
.py_list table {background-color: #ffeecc}
Here's an implementation of htmlstr(), basically for builtin types.
# Kragen Sitaker, 2001-12-05
# Produce HTML renderings of Python objects.
# For stylesheets: the followi
I was making the claim somewhere that NUL-termination made string
copying slower. It occurred to me that I ought to test that before
making the assertion; indeed, this program shows that at the
one-kilobyte level on my laptop, it's slower by about a factor of 6.
#include
#include
#include
#in
In Unix, many of the bigger violations of the principle of least
privilege stem from the rule that only root can bind to TCP or UDP
ports below 1024. Many network daemons run as root just so they can
do this.
This pair of programs illustrates how you can have a small, simple
program bind to the
This is a little larger than the normal posts on this list. Some of
this code shows promise of being useful, but it still needs quite a
bit of spit and polish in my eyes. I'm only posting it here because
other items in the hacks queue use it.
begin 644 MetaPy-6.tar.gz
M'XL(".-)$3P"`TUE=&%0>2TV+
I seem to have a thing for writing "simple" markup languages that get
translated to HTML, because HTML is both too slow to type and too hard
to read for my taste. I started doing this in 1994 with a bunch of m4
macros called "htm4". This hideous mess of kludges is the fourth one,
and I like its
contents, and lets viewers look at the subset
of your images containing a particular thing.
This software is not public domain, but copyright Kragen Sitaker 2001;
it is licensed under the GNU GPL version 2.
begin 644 picturepages-1.tar.gz
M'XL(`-UPN3L``^1;37/;2)+U=2KV1U3HTE($34MVVQZW3Y1$6=
work. (-i /usr/bin:/bin would work;
-i /usr/bin:/bin -d /bin would fail.) So I had the choice of (a) having
subtly buggy behavior; (b) rejecting reasonable input; or (c) writing
the code so that it would cope with reasonable input. I chose (c).
"""
#'#"# Unconfuse poor
I've often wanted something that can record byte streams with timing
intact and play them back with the timing intact. So someone FoRKed a
site you could telnet to (towel.blinkenlights.nl, I think) to get
played an ASCII-art movie of Star Wars, and after watching a bit of
it, I knew I wanted a co
A long time ago, I posted an ASCII-art download meter in Perl to
kragen-hacks. It drew a little progress bar in equals signs and
estimated what time the file would finish downloading. Here's a
version with Python and Tkinter.
It's useful even when iconified, at least if you're using a window
ma
when there are exceptions; oh well. Otherwise, it
seems unchanged.
#!/usr/bin/env python
import os, urllib, re, sys
from Tkinter import Radiobutton, Toplevel, Button, Tk, mainloop
# Handy little button bar for looking things up.
# Original version was in Tcl.
# Kragen Sitaker, 2001-10-24; public
This should be available at http://pobox.com/~kragen/sw/newreload-2.tar.gz
"""newreload: a better reload() for Python
reload() has some bugs --- well, let's say documented behavior I don't
like:
1. modules the reloaded module imports don't get reloaded. This means you
have to know something
Note that this program uses stuff from MetaPy, which I posted here
previously, and which is also available from
http://pobox.com/~kragen/sw/MetaPy-6.tar.gz.
#!/usr/bin/python
# I have some lists that have the following characteristics:
# - not time-sensitive: it's generally OK if stuff gets sent
Python has this package called Numeric (or Numerical Python, or
Numpy), which provides APLish (or PV-WAVE IDL-ish, or PDLish)
multidimensional homogeneous arrays of numeric data, of the sort one
often encounters in scientific computing. It provides aggregate
operations on these, such as elementwi
Solution of "word squares" was a popular amusement among word freaks
in the 1800s. A word square is a square grid of letters that reads
the same horizontally and vertically; for example,
B e a
e a r
a r c
Here's a program to produce word squares, given an initial seed word
or two. It runs und
In some discussion on ll1-discuss, Olin Shivers talked about how nice
it was to have lower-case parens. Here's my xmodmap file that lets
users of X have lower-case parens by swapping them with square
brackets.
After using my keyboard this way for about a month, I'm mostly used to
it, although I
"""Hash consing is a technique for implementing immutable conses (or
whatever compound data structure) where you store all the living
conses in a weak hash table, indexed by their children. The cons
routine looks in this table whenever it is called; if it finds it is
being asked to make another c
# something you might want to do: trace imports. For example, if
# you're writing a module that does something special with some kinds
# of objects from urllib, but is useful without urllib being loaded,
# you might not want to import urllib if your caller didn't already
# import it. But if it i
Sometimes, especially when I'm using my cell phone as a modem, I want
to get online, download my new mail, upload whatever mail I have ready
to send, and get offline as soon as possible.
Here's the system I use for this at the moment. I run this shell
script to control everything; pon and poff a
I wanted to call this "colapse", because it seemed like the perfect
term, but that seems to be a widely-used word. Google finds 5560
hits, both misspellings and other things.
"oerlap" isn't quite as apt a term, but it isn't used for anything
else, except as a rare misspelling of "overlap".
I occasionally run across the problem of matching one of a number of
fixed strings in text. A very efficient way to do this is to build a
deterministic finite automaton which will halt with success upon
recognizing any of the strings, or halt with failure upon recognizing
a string that is not a p
ty and put something like the
following in the appropriate files in your pam.d directory:
auth required pam_http.so url=https://ourserver.example.com/
Copyright Kragen Sitaker, 2001. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the G
This program had a couple of those forehead-slapping moments.
In early November, I'd moved my web pages from www.dnaco.net to
www.canonical.org, but www.dnaco.net was still getting hits --- one of
my pages referred explicitly to its imagemap.cgi program, because it
had a server-side imagemap in i
It has been asserted that passwords are obsolete, because they are
either too long to memorize or too easy to crack by exhaustive search.
This program generates strongly random passwords using data from
/dev/random that are both short enough to memorize and type accurately
and impractical to attac
Learning Common Lisp, and especially reading Paul Graham's
just-published-on-the-Web _On Lisp_, I often wish for a quick online
help program that will tell me what a particular Lisp idiom means.
Kent Pitman made this awesomely cool thing called the Common Lisp
HyperSpec, which weighs in at 18 megs
Idea from Martin Hinsch's woosh:
http://wosx30.eco-station.uni-wuerzburg.de/~martin/woosh/
Implementation by Kragen Sitaker, not having read the woosh code; I
thought a prototype-based system would be more suited to the shell.
shoo makes your filesystem and shell into a prototype-based
o
depends on where you install it and what implementation of bc
you have.]
The idea is from Martin Hinsch's woosh:
http://wosx30.eco-station.uni-wuerzburg.de/~martin/woosh/
Implementation by Kragen Sitaker, not having read the woosh code; I
thought a prototype-based system would be more suited
>From something on lambda.weblogs.com.
#!/usr/bin/python
"""Compute the longest "add-a-gram" from a word list.
The problem is from http://www.itasoftware.com/careers/programmers.php
Add-A-Gram
An "add-a-gram" is a sequence of words formed by starting with a
3-letter word, adding a lett
eed to have a kernel
compiled with /proc and APM support.
I run it in a small xterm without any arguments.
"""
import re, select, os, time, sys
__author__ = "Kragen Sitaker <[EMAIL PROTECTED]>"
__date__ = "2001-10-24"
__version__ = "2" # version 1 was
I wrote this script to tell me what files seemed likely to need
backing up. It doesn't work nearly as well as I'd like, mostly
because dpkg doesn't manage all the files I wish it did.
Here's the rationale:
To make my laptop easy to back up, I will segregate things that need
backing up and thing
This is pretty lame, even for kragen-hacks. But it might tell someone
how to do something actually useful at some point.
#!/usr/local/bin/python
# 'tkcat'
# How to handle asynchronous filehandle (stdin/stdout) I/O (on Unix)
# from the Tk event loop in Python --- mostly in the nature of an
# exec
Python includes a zipfile module, which uses zlib to give you read and
write access to zipfiles. Info-ZIP unzip, the standard unzip for
Unix, is in Debian non-free for some reason, probably because its
license doesn't meet the Debian Free Software Guidelines; this is a
free-software alternative.
The simplest useful XML parser application is one that copies an input
XML document, or at least copies interesting parts of it, to some
output. Here's an implementation of that application using Python's
standard XML support modules.
#!/usr/local/bin/python
# simplest useful XML application
imp
uot;~" nil t) (replace-match "~t" nil t)
; maybe I should use tempo.el for this?
(defun start-message ()
"Start a new mailmsg.py message at the end of the buffer."
(interactive)
(end-of-buffer)
(insert "~m\n")
(save-excursion
(insert-s
import sys, getopt
__author__ = "Kragen Sitaker <[EMAIL PROTECTED]>"
__version__ = "2"
def ruler(width, ansi=0):
"""Return an ASCII ruler for counting columns."""
rv = ''
for i in range(1, width+1):
i
o "-- $NICK joins" >> "$CHANNEL"
perl -pe '$|=1; s/^/<'"$NICK"'> /' >> "$CHANNEL"
echo "-- $NICK quits" >> "$CHANNEL"
--
<[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kragen/>
A good conversation and even lengthy and heated conversations are probably
some of the most important pointful things I can think of. They are the
antithesis of pointlessness! -- Matt O'Connor <[EMAIL PROTECTED]>
eturn map(lambda item: item[1], rv)
class filterdata:
"Return only data items matching a filter."
def __init__(self, datasource, filter):
self.datasource = datasource
self.filter = filter
def next(self):
while 1:
next = self.datasource.n
me(mainwin)
areaframe.pack(expand='1', fill='both', side='top')
arealabel = Tkinter.Label(areaframe, text='Max area:')
asl = Tkinter.Scale(areaframe, orient='horizontal', command=setthreshold,
to='1000')
arealabel.pack(side='left')
asl.pack(expand='1', fill='both', side='top')
#wiggle(c)
areashorten(c)
angleshorten(c)
Tkinter.mainloop()
--
<[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kragen/>
We have always been quite clear that Win95 and Win98 are not the systems to
use if you are in a hostile security environment. -- Paul Leach
The Internet is hostile.-- Paul Leach <[EMAIL PROTECTED]>
F7S,^_WG/MX5SV$\#[G-,;[G*,4[P_=*7N7VN0N\N[R9P3>U38X
MWD7;#J_T1Z67WJ?2,2_+%:==V@B*L4ZC@+8,767A`&B/OD@$W('^.,\B9=+G
M?86Y.4O]KIIE>;_S8L&[6NKD_3\D-GG\I\TJ?8AR'3@^$?\;NWO[L^__]IM\
M_WNWM;>._U^B'#X[>O3\'?;).Q_HNF?G=0M[I=+1B\?<=E1/35)O-YMO]^MT
MX+03X1U_AZ52ICCW
0;
while (not $brokenpipe and defined($_ = <$outsocket>)) {
$gotstuff++;
print ".";
print $socket $_;
}
print "\n";
if (not $gotstuff) {
print "No data; brokenpipe is $brokenpipe and errno is $!\n";
}
close $outsocket;
close $socket;
}
--
&l
nless $echo =~ /^at#pbokr=$i/;
my $line = ;
if ($line eq "OK\r\n") {
print "No phonebook entry $i\n";
} else {
print $line;
expect_ok;
}
}
cleanup;
--
<[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kragen/>
I don't do .INI, .BAT, .DLL or .SYS files. I don't assign apps to files. I
don't configure peripherals or networks before using them. I have a computer
to do all that. I have a Macintosh, not a hobby. -- Fritz Anderson
uot;)\n"
"Home dir: " 6 "\n"
"Shell: " 7 "\n")
forms-field-sep ":"
forms-multi-line ",")
--
<[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kra
I was participating in a discussion on another mailing list about how
to make it more expensive, and thus less attractive, to commit spam.
I needed to do a fair bit of calculation for this, so I had the
opportunity to reflect on current technology.
I find the traditional REPL extremely annoying f
skippedit, newstring,
# bitindexofdifference)
def first_bit_difference(string1, string2):
for charindex in xrange(min(len(string1), len(string2))):
if string1[charindex] != string2[charindex]:
bitstart = charindex * 8
for bitindex in range(bitstart, bitstar
/* a simple oscilloscope program I wrote between 14:30 and 19:00 one
* afternoon while sitting in a mixing studio watching _K-19: The
* Widowmaker_ being made. We had just walked into a junk store where
* I had resisted buying a real oscilloscope, and I thought it would
* be really nice to ha
length == 1) {
finger(arguments[0]);
} else if (arguments.length == 2) {
finger(arguments[0], arguments[1]);
} else {
System.out.println(USAGE_MSG);
}
}
}
--
<[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kr
uot;
(interactive "r")
(save-excursion
(goto-char end)
(let ((endm (point-marker)))
(unwind-protect
(progn
(goto-char start)
(while (and (<= (end-of-next-word) endm) (< (point) endm))
(pig-latin-next-word)))
(set-marke
/* I wrote this program to test how feasible it was to fake a slow
* network connection by twiddling SO_RCVBUF. The idea is to read
* data from the socket relatively slowly, but keep SO_RCVBUF small
* from the beginning of the connection to make sure that the remote
* side's TCP is aware that
-
<[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kragen/>
When the battle between "us" and "them" is equated with the battle between
good and evil -- then we have placed ourselves above all evil. This is to
make gods of ourselves. -- Steve Talbot, NETFUTURE #129, via SMART Letter
t/product.asp?entity=CableWorld&pf_ID=7A2ACA71-FAAD-41FC-A100-0B8A11C30373";.
Similarly, diff output is incomprehensible, because the line
boundaries that are so important to its semantics get lost; embedded
quotes and parenthetical remarks of any kind are difficult to
understand, bec
nteresting words like 'adherent'
* too. */
if (!canonicalize(word, modword, len)) continue;
canonicalize(word + len, modword + len, len);
if (!memcmp(modword, modword + len, len)) fputs(word, stdout);
}
return 0;
}
--
<[EMAIL PROTECTED]> Kragen Sitaker <http://
duce (filterer (lambda (x) (zerop (mod x 3 '(1 2 3 4 5 6 7 8 9 10)
:from-end t :initial-value '())
--
/* By Kragen Sitaker, http://pobox.com/~kragen/puzzle2.html */
char a[99]=" KJ",d[999][16];main(){int s=socket(2,1,0),n=0,z,l,i;*(short*)a=2;
if(!bind(s,a,16))for(;;){z=16;if((l=recvfrom(s,a,99,0,d[n],&z))>0){for(i=0;i
se:
sys.stderr.write("Usage: %s remotehost remotemaildir localmaildir\n" %
sys.argv[0])
sys.exit(1)
# fixed bug log:
# - forgot \n on usage message
# - wrote 'else return astring' without a ':' after 'else'
# - forgot
I thought I'd posted this before, but it doesn't look like I did. icb
is a chat system that helps people waste their time by typing inane
comments at each other, similar to IRC; its primary advantage is that
it is technically more primitive than IRC, so most people don't bother
to use it.
Rather
os.readlink(os.path.join(self.docsdir(), filename))
def main(argv):
if len(argv) < 2:
sys.stderr.write(usage + "\n")
return 1
if not os.path.exists(argv[1]):
sys.stderr.write("No such indexdir: " + argv[1] + "\n")
return 2
't chdir $indir: $!";
die "zip failed" if system "zip", "-qr", $zipfile, $subdirname;
}
# delete everything under some possibly-maliciously-named directories
sub cleanup_dirs {
system 'rm', '-rf', @_;
}
sub main {
my ($script, $zipfilena
pixels in the output.
My intuition tells me this will not work for N < 3.
The saturation problem
--
Although I haven't tried it, I think this process will tend to
desaturate color images. I'm not sure how to fix that.
One general technique that might reduce the
ixed-bug log:
# - forgot \n on usage message
# - wrote 'else return astring' without a ':' after 'else'
# - forgot to return rv from locations()
# - the following incompatibilities with 1.5.2:
# - used string methods .replace and .rfind
# - used zip()
# - didn't handle t
Some years ago, I had this idea for a computer game based on driving a
car. So I learned Xlib so I'd be able to write the game, but in the
process, I got distracted. Yesterday morning, I wrote a primitive
version of this game, which is included below.
begin 644 derivgam-1.tar.gz
M'XL(`'&=T``^
e.redirect(url)
return REQUEST.response
return redirect
# stupid Zope overhead
def addForm(dummy):
"""Add a ShortURLs object."""
return """Add ShortURLs
id
Submit this!""" % (`dummy`,)
def addFunction
persists, either your
browser doesn't support JavaScript or this page is broken for you.
Note that, as of this writing (2002-08-01), the underlying mediator
software doesn't do a very good job with words containing '"' (the
double-quote character), '/' (the slash c
ssert that says the strings must
# differ at min_newcommonlen if they had different numbers of chars in
# common with their common parent was using the previous value of
# curlens[which] rather than its current value. This was wrong.
# read_locatedb didn't always take initial_curlen and in
Now it features a /moron command to translate a certain dialect into
English and a /shorten command to toggle automatic shortening of URLs.
I added the /shorten feature because people kept pasting these annoying
shortened URLs into ICB; I couldn't tell if I'd visited them or not, or
whether they
assert atom('a') != atom('b')
assert integer(1) == integer(1)
assert integer(1) < integer(2)
assert integer(2) > integer(1)
assert variable('a') == variable('a')
assert variable('a') != variable('b')
assert a
', str(insttree)
### comparison
assert atom('a') == atom('a')
assert atom('a') != atom('b')
assert integer(1) == integer(1)
assert integer(1) < integer(2)
assert integer(2) > integer(1)
assert variable('a') ==
onnector, reason): connector.connect()
def clientConnectionFailed(self, connector, reason): reactor.stop()
def main():
irccf = blogbotfactory()
reactor.connectTCP("localhost", 6667, irccf)
reactor.run()
if __name__ == "__main__": main()
--
<[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kragen/>
Edsger Wybe Dijkstra died in August of 2002. The world has lost a great
man. See http://advogato.org/person/raph/diary.html?start=252 and
http://www.kode-fu.com/geek/2002_08_04_archive.shtml for details.
x27;a(b(a d) a)', str(insttree)
insttree = atree.instantiate({'c': atom('b'), 'e': atoma})
assert str(insttree) == 'a(b(b d) a)', str(insttree)
### comparison
assert atom('a') == atom('a')
assert atom('a') !=
v
def __call__(self, *args):
rv = instance()
for (field, value) in zip(self.args, args):
rv.__dict__[field] = value
rv.__dict__['fields'] = self.args
rv.__dict__['primary_key_fields'] = self.kwargs['primary_key']
rv.__dict__[&
ubstr($word, -2));
}
sub miellpssed {
my ($line) = @_;
my @chnuks = split /\b([a-zA-Z]+)\b/, $line;
return map { misspell_word $_ } @chnuks;
}
if (defined $ARGV[0] and $ARGV[0] eq '-a') {
shift;
$trafnosrm = \&alabehiptze;
}
while (<>) {
print miellpssed $_;
}
--
<
= rvdict[item] + 1
except KeyError:
rvdict[item] = 1
rvlist = []
for item in lists[0]:
if rvdict[item] == len(lists):
rvlist.append(item)
return rvlist
def uniq(alist):
rvdict = {}
for item in alist:
rvdict[item] = 1
return rv
if char in '123':
c.shrink(int(char))
elif char in [backspace, delete]:
c.expand()
elif char == '?':
msg = c.dump() + ' '
else:
msg = "unknown
Q"(7W:.J%@G
M9S+@L4;;2M4Z6H\+>@%?GRL$%&;^/2RWI76T[XG3`P\*SJ&N(@O!-R.7Y$GN
M1U[3/DJA@*[4K^IP.1$PRH>#W879WC=,V[,[V=I\B)Z[/"_8%K((5NNHBENO
M@GL('5>'8$)'*D*9A-MQK-`4RG5I+L9<`L.US0.\FQ7&K9XO[#G'+I.B7OGD@UY;BIX),V&NW,8
MN(-"M!$O0'LTR\5[>
;Inputs: ");
for (ii = 0; ii < ninputs; ii++)
printf("%c ", varname(ii));
printf("\n");
}
maxgates = max_gates_for_inputs(ninputs);
done = 0;
for (ngates = 0; ngates <= maxgates; ngates++) {
printf("Trying with %d gates...\n", ngates);
free(cp);
cp = newci
elist = gtk.GtkCList(2, ["From", "Subject"])
thelist.append(['[EMAIL PROTECTED]', 'I have a book you might like'])
thelist.append(['[EMAIL PROTECTED]', 'How are you?'])
thelist.columns_autosize()
vbox.pack_start(thelist)
window.show_all()
th
;, '76'),
('powerful', 'rejection of: somebody'),
('following', ''),
(),
('eof')], tw.output
test()
def setup_mailbox(clist):
dbroot = conn.root()
I just got Apache and perl running inside a chroot jail; this required
that I make some libraries and also all of /usr/lib/perl5 available
inside the chroot jail. So I wrote one program to hardlink libraries
into the jail, and another to hardlink all of /usr/lib/perl5. (Some
people prefer to copy
I described some of the problems I have with file and backup
management in a kragen-tol post in March 2002, entitled "file
catalogs and backups":
http://lists.canonical.org/pipermail/kragen-tol/2002-March/000691.html
http://www.mail-archive.com/[EMAIL PROTECTED]/msg00037.html
Now, spurred by recen
So I wanted to do my taxes. I wrote a 'tax2003' Python module containing
a bunch of stuff like this:
class employer1:
earnings = 12345.67
federal_wh = 1234.56
class employer2:
earnings = 123456.78
federal_wh = 12345.67
class form1040:
# income
wages = employer1.earnings
TWOKEY
--
This is a crude prototype of a five-key input method based roughly on
Tegic T9, PBX extension directories, and various Chinese and Japanese
input methods for Chinese characters that I've used. Basically, to
enter text written with a large alphabet, you enter the text with a
small al
#!/usr/local/bin/perl -w
use strict;
# This script turns a table from a web page into a list of hash refs,
# according to whatever headers it finds on the first row of the
# table. You'll need libwww-perl an HTML::TableExtract installed to
# make it run; this implies also the URI, MIME::Base64, D
(b(b d) a)', str(insttree)
### comparison
assert atom('a') == atom('a')
assert atom('a') != atom('b')
assert integer(1) == integer(1)
assert integer(1) < integer(2)
assert integer(2) > integer(1)
assert variable('
This is a GUI version of the two-key input method I prototyped last
summer, with an eight-way pie menu. It needs a reasonable word list
to run reasonably. It's written in Python with PyQt, so you'll need
those installed in order to use it, and it might require a recent
version of Python, too.
A
Like other things posted here without notices to the contrary, this
code is in the public domain.
You can find partial hash collisions by sorting the hashes and then
walking through the sorted lists looking for successive entries with
long common prefixes. I was going to write a program to do tha
Like other things posted here without notices to the contrary, this
code is in the public domain.
Here's qd.py:
def chomp(text):
while text[-1:] in ['\r', '\n']: text = text[:-1]
return text
assert chomp('a\n') == 'a'
assert chomp('\n') == ''
assert chomp('') == ''
def untabify(text):
Like other things posted here without notices to the contrary, this
code is in the public domain.
So lately I've been using this program to read my email. It's
intended as a quick-and-dirty prototype of query-based mailreading.
Apparently there's a program called 'mboxgrep' that does something
si
Like other things posted here without notices to the contrary, this
code is in the public domain.
#!/usr/bin/python
# I'd use the MetaPy dict mixin if I had one handy
"""A crude dictionary backed up by log-structured file storage.
This hack is just a proof of concept. The concept is that it's re
Like other things posted here without notices to the contrary, this
code is in the public domain.
So some LiveJournal meme was going around --- this list of 100 movies
where you'd bold the ones you'd seen and post it on your journal. So
I wrote a CGI script to make it easier, which was pretty sil
Like other things posted here without notices to the contrary, this
code is in the public domain.
I recently posted a prototype pie-menu-based input method that
included the cryptic message:
# some research from mine in June, redone with a better wordlist
# in October, suggested '
Like other things posted here without notices to the contrary, this
code is in the public domain.
I wrote about this before, using nested S-expressions and stuff. I
got very similar performance results this time around, with a slightly
simpler data format, and a slightly different set of metadata
Like other things posted here without notices to the contrary, this
code is in the public domain.
This program depends on a recent Python and PyQt.
I was experimenting with incremental full-text filesystem search.
This program is probably a little too clever about caching, and
clearly not clever
Like other things posted here without notices to the contrary, this
code is in the public domain.
This is a relatively responsive pager program for text files, much
like 'more' or 'less', but in a GUI, so it zooms in and out with the +
and - keys.
It's written in Python with PyQt.
#!/usr/bin/pyt
It occurred to me that quadtree compression would probably work really
well for screenshots and possibly even sequences of screenshots. So I
hacked together something one night to do quadtree compression of
small arrays of values in Python.
#!/usr/bin/python
"""Quadtree image compression library.
I implemented this BER decoder in order to help me understand SNMP
packets and debug an SNMP implementation I've been working on.
Itself, it's too slow to be useful in the implementation, but it's
great as a debugging tool. Feed it e.g. SNMP packets.
It is guaranteed to break on BER-encoded thing
Festival has a Sable XML DTD you can use to adjust the speed of
utterances, but it doesn't seem to adjust the lengths of pauses. The
default speech speed is far too slow for pleasant use. Here's a
little hack to speed up text-to-speech output a bit, with little
leftover bits in the middle to try
y down to like
kind of awkward around her, and really quiet
did she visit his hometown?
/*kragen sitaker*/
(function() {
var map = function(array, cb) {
var rv = [];
for (var i = 0; i < array.length; i++) { rv[rv.length] = cb(array[i]) }
return rv;
};
var maptblrows =
I've tried this on my most recent 200MB of email, and it seems to work
OK. Future directions include:
- result ranking: most recent is not always best!
- handling bigger corpuses
- word-prefix search (krag*)
- field search (krag* in To)
- incremental search and display
Indexing 200MB of email, am
Thursday afternoon, after work, I hacked the full-text mail indexing
program from last weekend so it could handle arbitrarily large
mailboxes. It generates N small indices, each small enough to easily
fit into memory, then does an N-way merge on them. On Gentle, which
is a 500MHz AMD K6 with 64kB
The Python text indexer I posted here last weekend (and, I think,
again yesterday) is too slow. Friday, after work, I hacked out
something in C to see if I could get it to be faster. It's about 10
times faster than the Python version, but it lacks some features:
- it doesn't yet do the case-insen
Compatible with previously-posted Python programs, but it's a bit
fiddly to get them to work together still. Much faster. May be
enjoyable if you like optimization.
/*
maildex: find words, index by mail message byte offset
This program computes an inverted index for a mailbox file, in the
same
#!/usr/bin/python
# relational algebra in Python 2.3
# Allows you to construct simple relational algebra queries in Python
# and translates them on the fly to SQL. Then you can iterate over
# the query results, which are Python dictionaries. I've tried this
# in Python 2.3, but maybe it might wo
/*
* hash tries.
*
* Herewith a program that can dynamically construct and run a
* deterministic finite state machine, such as for matching to a trie
* or a regular expression, over a sequence of bytes, at under 100
* clock cycles per byte, and under 50 (potentially 25) bytes of
* memory per
1 - 100 of 128 matches
Mail list logo