Miscellaneous Code Snippets

colorls -h

This patch adds the -h switch for reporting sizes in a human readable format to misc/colorls from NetBSD®'s pkgsrc. Unpack the tarball into $LOCALPATCHES/misc/ and rebuild colorls (note that $LOCALPATCHES must be defined in /etc/mk.conf for this to work). For example:

$ echo LOCALPATCHES=/usr/local/patches >> /etc/mk.conf
$ mkdir -p /usr/local/patches/misc
$ cd /usr/local/patches/misc
$ tar xzvf /path/to/colorls.tar.gz
$ cd /usr/pkgsrc/misc/colorls && make update clean

Download: colorls.tar.gz

timeout

$ timeout 60 foo

executes the command foo with a timeout of 60 seconds. If the executed command has not exited before the timeout has expired, the timeout tool sends SIGTERM (or the signal specified via the optional first argument) to the executed command. If the timeout tool receives a signal, it will forward the signal to the executed process — apart from that, the signal is ignored (this is true for most signals, including SIGTERM, but not for all signals). This allows for constructs such as:

$ timeout -TERM 60 timeout -KILL 70 foo

Note that in this example, the timeout command which sends SIGTERM must be specified first, as SIGKILL cannot be forwarded by a following timeout to foo.

Download: timeout.c

range2mask

Takes two IPv4 addresses which specify some subnet range as it's arguments and spits out the CIDR network address and netmask. For example, the following command would return "net: 217.197.84.160/29 mask: 255.255.255.248":

$ range2mask 217.197.84.160 217.197.84.167

Download: range2mask.c

runon

Just a few lines of C which emulate IRIX®' runon command on multi cpu machines running SunSolaris®. runon binds a process to the cpu specified on the command line. For example, the following command would run netscape only on the second cpu (where the first cpu would be 0):

$ runon 1 netscape http://www.google.de/

Download: runon.c

xterm-latin9toXft

This is a small patch against xterm(1) #225 which hardcodes the mapping of ISO-8859-15 characters to Unicode fonts used via Xft(3)/FreeType. This is useful only if (1) an ISO-8859-15 locale(7) is used; (2) a Unicode font is used via Xft (as this isn't handled by XTerm's builtin "mini-luit"); and (3) using luit(1) is not an option for some reason (I don't use it because with luit, <Ctrl>-V and some other control characters must be escaped—at least I don't know how to circumvent that). In short, this patch extends XTerm's "mini-luit" to Xft fonts, though hardcoded. That is, the character conversion will always take place for Xft fonts, regardless of XTerm's configuration and the actual locale settings.

Download: xterm-latin9toXft

nextssh.sh

Bourne shell script that automagically downloads, patches, builds and installs ZLib 1.1.4, OpenSSL 0.9.7b and OpenSSH 3.6.1p2 on NeXTStep (tested on NeXTStep 3.3). You need, of course, a C compiler installed (tested with GCC 2.5.8), you need Perl (tested with Perl 5.004) and you need Patch (tested with GNU Patch 2.1). Simply download nextssh, have a look at the variables at the top of the script and run:

$ chmod 755 nextssh.sh
$ ./nextssh.sh

Download: nextssh.sh


Valid XHTML 1.1!  Valid CSS!  Powered by Debian GNU/Linux

Last modified: $Date: 2020/08/21 07:04:25 $ by Holger Weiß