Junk

Here are some fun things that I have worked on (hacked up in a few minutes) that I thought I should share. More serious projects I work on can be found here.


screenshell

I recently wanted a way to set up a machine as a serial console server. That is to connect two of its serial ports to serial ports on two other machines using a null-modem. The idea being that these other machines would put their console on their serial port which would be accessable remotely. Good for debugging, good for handling crashes.

Rather than users logging into the console server and then executing a command to access the relevant serial port, I wanted access to be I wanted access to the consoles by telneting to a designated port, one port per serial console that is available.

To achieve this I wrote a small script, screenshell and put it in /usr/local/bin. It is pretty simple, it creates a new screen session for the requested TTY if one doesn't already exist, else it connects to the existing session. I couldn't find an argument to screen that would do this in one hit, so the script looks at what screen sessions are running and acts accordingly - some room for improvement here.

In order to accept connections via telnet, I just added the following lines to /etc/inetd.conf.

8000		stream	tcp	nowait	scs.scs	/usr/sbin/tcpd /usr/sbin/in.telnetd -h -L/usr/local/bin/screenshell-ttyS0
8001		stream	tcp	nowait	scs.scs	/usr/sbin/tcpd /usr/sbin/in.telnetd -h -L/usr/local/bin/screenshell-ttyS1

This basically says, listen for connections on port 8000, if you get a connection, invoke /usr/sbin/in.telnetd and use /usr/local/bin/screenshell-ttyS0 to handle their session. Similarly for port 80001. scs.scs denotes that /usr/sbin/in.telnetd should be invoked as user scs, group scs. The scs (Serial Console Server) user and group were created for this sole purpose, though that is really just a matter of taste.

I couldn't work out how to determine which port the user was connecting to from within screenshell when it is invoked in this way, nor could I work out how to pass extra arguments to screenshell. So instead I just symlinked screenshell to screenshell-ttyS0 and screenshell-ttyS1, which allowed the command name to be used to determine which TTY was being used. Again, room for improvement.

For the problem at hand telnet was sufficient so I didn't investigate how well ssh would work with the solution that I cam up with. For the task at hand, the solution above seems to work quite well.

screenshell

History of dubious utility:
1st May 2009: New
4th May 2009: Use screen -xRR -S NAME, thanks to kfish


genBlog

I got sick of the old brokenness of by RSS feed, and have written by own feed generator, with the help of Alex.

genBlog
(New: 2nd February 2007)


mail.xargs

This is a perl script based on Mail::Box::Manager which given an mbox on stdin, will execute the command given as arguments once on each file. Kind of like xargs --max-args 1, but for mailboxes.

# mail.xargs sendmail < ~/INBOX

It could also be extended to handle maildir without too much effort, assuming Mail::Box::Manager supports maildir, but I haven't got that far yet.

For documentation, please run: perldoc mail.xargs

To produce a man page, please run: pod2man --section 1 mail.xargs > mail.xargs.1

mail.xargs
(New: 9th August 2006)


tiff_find

I recently started working on an Imlib2 loader for Nikon's NEF format as I want to play with the NEF files that my my D70 can produce. The loader implementation will probably used libtiff, and the code I have so far does that. However, I was having some trouble working out exactly what values are where in the TIFF, so I wrote a tiff directory decoder from scratch. Its some what limited, but it should be able to give you a directory listining given a TIFF. Well, an NEF from a D70 anyway.

tiff_find.c, Makefile
(New: 27th April 2006)


sort-hr

Sort the human readable output of du -h, ls -h, etc...

# du -sh ~/lang/c/e/cvs/e17/* | sort-hr 
16K     /home/horms/lang/c/e/cvs/e17/CVS
116K    /home/horms/lang/c/e/cvs/e17/oe
6.9M    /home/horms/lang/c/e/cvs/e17/docs
14M     /home/horms/lang/c/e/cvs/e17/proto 
64M     /home/horms/lang/c/e/cvs/e17/libs
81M     /home/horms/lang/c/e/cvs/e17/apps

sort-hr
(New: 26th April 2006)

Update: 27th April 2006
I was concerned that the inital method, of expanding the reported sizes out to an integer might overflow, so instead the unit is compared separately to the value. The input parsing has also been made more robust.


ndebootstrap

Create a Debian root directory, suitable for use with NFS-root, using debootstrap. Actually, its probably useful for other things too. debootstrap is almost there, but not quite.

Note: This script doesn't work as well as I had first throught. I'm working on some fixes. So if you have some suggestions, please send them my way.

ndebootstrap
(New: 17th April 2006)


PSP Language Settings

If you have a PSP (Play Station Portable) in Japanese, and you want to change it to English, and you don't read Japanese and thus can't read the menus, this page is for you. more...

New: 7th January 2006


dpkg-unpack-build

Given a tar-ball, if there is a debian/ directory inside unpack the tar-ball and try to build a debian package from it.

Given a .dsc file (and associated tarball and possibly diff), try to unpack and build a debian package from it.

Download: dpkg-unpack-build
(New: 27th December 2005)


power-toggle

Query and Change the power states of outlets controlled by an APC PDU. It always toggles the first available outlet, Assuming that each user only having access to one outlet. I'm not sure if the other configurations are even possible.

# power-toggle 172.17.100.1 7 pass status
STATE: ON
# power-toggle 172.17.100.1 7 pass off
Turning off...
# power-toggle 172.17.100.1 7 pass off
Already off...
# power-toggle 172.17.100.1 7 pass reset
Turning on...
# power-toggle 172.17.100.1 7 pass reset
Turning off...
Sleeping for 10s...
Turning on...

Download: power-toggle

Update: 2nd May 2005
Exit with 0 on status request if the status is ON, 1 otherwise. The previous behaviour was to always exit with 0.

Update: 8th May 2009:
Allow login as Admin


ccache-update-links

ccache is a compiler cache. I find it greatly reduces compile time when I have to recompile the same code over and over, which is often the case when I prepare Debian packages.

It can be invovked in a variety of ways. For me the easist is to make a symlink the name of the compiler in my path. For example, ~/local/bin is in my path before /usr/bin, and I want all invocations to gcc to use the compiler, so I do this

# which gcc
/usr/bin/gcc
# (cd ~/local/bin-ccache && ln -s /usr/bin/ccache gcc; ) 
# which gcc
/home/horms/local/bin-ccache/gcc

So now, as long as ~/local/bin-ccache is in my path, whenever I invoke gcc it actually runs ccache, which does its magic and calls /usr/bin/gcc as needed. As ccache invocations look exactly the same as gcc invocations, this means its easy to get ccache into a build.

# which gcc                                       
/usr/bin/gcc
# ccache-update-links ~/local/bin-ccache 
# which gcc
/home/horms/local/bin-ccache/gcc

But with different versions of gcc, and recently doing some work with cross-compilers, I have a lot of symlinks I want to create, and this is a bit of a chore. So I wrote a ccache-update-links to do this for me. Note that it actually just creates and overwrites links, it doesn't know how to delete dead links. Perhaps I should add that...

By default it searches all the directories in the PATH environment variable, the list of paths to search can be overridden by setting SEARCH_PATH in the environment.

 # which gcc                                       
 /usr/bin/gcc
 # SEARCH_PATH=/usr/bin:"/usr/local/bin" ccache-update-links ~/local/bin-ccache
 # which gcc
 /home/horms/local/bin-ccache/gcc

Download: ccache-update-links
(Updated: 12th July 2005)


E-Biff

New images for enlightenment's E-Biff.

No New
Messages
New
Messages
9 Messages,
7 New
New: [nomail]
[png] [xcf]
[newmail]
[png] [xcf]
[7of9]
[png] [xcf]
Original: [nomail]
[png]
[newmail]
[png]
[7of9]
[png]


Saidict

I've been thinking of writing a supplementry Japanese-English diectionary, basically for words I can't find in Edict.

So far I have an entry for "retranslation function", courtesy of Yuichi Yoshida, the uim-anthy author.

Works wonderfully with Gjiten, and should work equally well in anything that supports edict format dictionaries. Though it would be arguably more useful if it had more entries.

Download: saidict.utf8

If you need another format, iconv, pkf and friends can do that for you.

Updates:
Various updates, including an entry for 'H' (Echi). 17th January 2006
Saidict has expanded 100% from one word to two. 18th November 2005
Saidict is bing updated several times a month at the moment. 27th April 2006 18th November 2005
134 entries and counting... 30th January 2007
Added some Aussie slang, 146 entries in total and counting... 5th February 2007


Okiniri add-on to Git

When working with Git I sometimes make wrappers to help me out. The only one I am currently using is okiniri-export. Its here in case anyone finds it useful.



"DELETED!!!" patch for Mutt

Inspired by Strong Bad's Email this patch modifies Mutt to display a nice soothing message each time a message or thread is deleted from the pager view. I find this particularly soothing while sifting through mailing-list threads.

######  ####### #       ####### ####### ####### ######  ### ### ###
#     # #       #       #          #    #       #     # ### ### ###
#     # #       #       #          #    #       #     # ### ### ###
#     # #####   #       #####      #    #####   #     #  #   #   #
#     # #       #       #          #    #       #     #
#     # #       #       #          #    #       #     # ### ### ###
######  ####### ####### #######    #    ####### ######  ### ### ###

Patch for mutt 1.5.4: mutt-1.5.4-strongbadsemail.exe.patch.txt
May or may not work with other versions of mutt.

Patch for mutt 1.5.5 mutt-1.5.5-strongbadsemail.exe.patch.txt
Includes .muttrc configuration option. Thanks to Ben Buxton.
Does not seem to apply cleanly to 1.5.4.

Patch for mutt 1.3.28 mutt-1.3.28-strongbadsemail.exe.patch.txt
Backport of 1.5.5 patch above.

Binary packages for Debian Unstable with this patch here.


"Pants" patch for the Linux Kernel

Tired of those pesky Kernel Panics when hacking up your latest driver/network destruction device?
Try Kernel Pants instead.

Kernel pants: Attempted to kill the idle task! 

Patch for Linux 2.6.15: linux-2.6.15.pants.patch
Patch for Linux 2.4.20: linux-2.4.20.pants.patch
May or may not work with other versions of the Linux Kernel

"The sheer worthiness of this patch is beyond what words can describe..." Raster

"Probably the most significant advancement in the Linux Kernel since Linus got his 386 to boot." Me

See also Kfish's Pants Init Script.


kfishd: An Implementation of Kfish in the Linux Kernel

If you know Kfish then you probably need this. Else you probably don't.

Kfishd Releases:

* May or may not work with other versions of the Linux Kernel

$ ps axf | fgrep kfishd
3032 ?        SW     0:00 [kfishd swimming] 

Jiten

Japanese-English/English-Japanese dictionary for the Sharp Zaurus.

Some things to note about this code

binary, source.