Fiddling with X selections from shell scripts
I know of three command-line programs that will fiddle with theX selection (and/or the cut buffers) in a way that's usefulfor shell scripts: xsnarf from Smarasderagd's collectionof X things , xcb , and xclip .
I use xsnarf for a variety of reasons, I think partly historical (inthat I had it around well before I found the others); I'm jotting downthe other two here partly so that I have the information handy the nexttime someone asks me
A simple way to get a disk space usage summary
In the spirit of my little shell scripts, here's a simple way to get auseful summary of disk space usage on a Unix system:
du | sort -nr | less
(substitute the pager of your choice for less , and use ' du -x ' asnecessary.)
This is less pretty than the various graphical disk space visualizationprograms that float around, but I find it gives me pretty much theinformation I need. It's pretty easy to narrow down what areas of thefilesystem,
An shell script idiom for choosing what file to operate on
This is one of those Bourne shell idioms where I show the code firstand explain the effect later:
#!/bin/shdef=$1; shiftcase "$#" in 0) if test -t 0; then cat -- $def else cat fi;; *) cat -- "$@";;esac
Call this selfile . You use it in things like log scanning scripts,invoking it as:
selfile /var/log/something "$@" | .
An obvious way to do bulk initialization of dictionaries
Every so often in my Python programs I need to initialize adictionary with a whole bunch of values (and then pass it offsomewhere). For a long time, my usual approach to this was:
d = {}d['a'] = b.whatd['c'] = foo(d)....Recently I stumbled over the better way to do this, which isembarrassingly obvious in retrospect:
d = { 'a': b.what, 'c紀行
七日倒數
Weekly spam summary on May 27th, 2006
This week, we:
- got 11,513 messages from 227 different IP addresses.
- handled 18,277 sessions from 912 different IP addresses.
- received 133,583 connections from at least 42,540 different IPaddresses.
- hit a highwater of 8 connections being checked at once.
This is about the same as last week . Tuesday,Wednesday, and Thursday were the busiest days this week for connections;I suppose that's not
Today's dilemma: wiki page or blog entry?
As time goes by, there's an increasing amount of stuff I want to writedown. One of the things that stalls me out on this (apart from the sheereffort of writing) is the question of where and how I should put them;in particular, should I make a wiki page or write a blog entry?
In theory this shouldn't come up; WanderingThoughts is part ofa hybrid wiki-blog, which I've extolled the virtues of before . In practice this is an illusion