gnome-screensaver and alternative window managers
June 30, 2009 at 10:15 PM | categories: psa | View CommentsI've been using gnome-screensaver with awesome for a while without any problems. Unfortunately that all came to an end when GNOME 2.26 hit Debian Sid last week. Just so that no-one else has to dig for this, gnome-screensaver now uses gnome-session to determine idle time. gnome-screensaver will run without gnome-session, but the screensaver and locking mechanism will never kick in. Fortunately, there is an easy fix. I changed my
gnome-power-manager &
line to
gnome-session &
in ~/.xsession and everything works now.
pcapy
May 21, 2009 at 09:21 AM | categories: python, psa | View CommentsSo, pcapy is a great, simple
library to interface with libpcap. It works well for reading live packets and
dump files. There's only one problem: there is no way to modify or create a
struct pcap_header from Python code. So there's really no way to add data to
the packets and add them to a dump file.
View a Certificate
May 20, 2009 at 11:10 AM | categories: tips | View CommentsYet another command I'll never remember unless I write it down. Here's how to view a certificate. In my case I was viewing a certificate that Mutt had stored:
openssl x509 -in .mutt_certs -noout -text
_hg_ps1()
March 31, 2009 at 09:23 PM | categories: mercurial, bash | View CommentsIn honor of the decision
to move Python development to Mercurial, I
decided to write something helpful. I've found __git_ps1() to be incredibly
useful, so, here's my take on _hg_ps1():
_hg_root()
{
local basedir=$(pwd)
while [ '/' != "${basedir}" ]; do
if [ -d "${basedir}/.hg" ]; then
break;
fi
basedir="$(readlink -f "${basedir}/..")"
done
[ '/' == "${basedir}" ] || echo -n "${basedir}"
}
_hg_ps1()
{
local g=$(_hg_root)
if [ -n "${g}" ]; then
local branch
branch=$(hg branch)
if [ -f "${g}/.hg/bookmarks.current" ]; then
branch="$(< "${g}/.hg/bookmarks.current"):${branch}"
fi
if [ -n "${1-}" ]; then
printf "$1" "${branch}"
else
printf " (%s)" "${branch}"
fi
fi
}
Yes, I know that the hg root command does the same thing as my _hg_root(),
but it felt slow running mercurial before printing each prompt. The only
thing that's missing is showing when merges are in progress. I'll try to add
that the next time I need to do a manual merge.
Update: It seems that some of my repositories don't have a .hg/branch file
so I'm calling hg branch for that info. Also, the readlink line in
_hg_root() did not properly handle spaces.
Saving ViM Macros
March 11, 2009 at 09:32 AM | categories: tips, vim | View CommentsI use ViM macros (aka complex-repeat) all the time. Occasionally, I find that it would be nice to reuse one of my macros across editing sessions. Turns out it's pretty easy to save the macro. Just add a line like the following to a file that gets sourced when your file is opened by ViM (This example is from ~/.vim/ftplugin/rst.vim).
let @h = "yypVr"
Now, whenever I open a ReStructured Text file, I can hit @h and my macro will run.
« Previous Page -- Next Page »