Archive for the ‘tricks’ Category

Getting mail clients to work with domains at Gmail

Monday, April 21st, 2014

My work email is and is actually maintained at

Both and mutt have had a hard time configuring for it.


  1. Set it up as normal for a Google IMAP account.
  2. Then go to Mail -> Preferences, select the account.
  3. Then on the “Outgoing Mail Server (SMTP):”, select by left click the server
  4. and then “Edit SMTP Server List …”.
  5. Now, select the server again
  6. First you’ll want to change the “Description” to be “” (this is in the “Account Information”)
  7. Second you will want to select Advanced
  8. Third, change the “User Name:” from “” to be “”

It should work now

For mutt, I followed the directions at Consolify your Gmail with MUTT with the exception of the following line:

set smtp_url = "smtp://"

I modified it to be:

set smtp_url = "smtp://"


Quick hack to rename all prefixed files in a directory to a new prefix

Sunday, April 13th, 2014

loghyr:xxx thomas$ ls -1 pnfswars* | sed ‘s/\(pnfswars\)\(.*\)/mv \1\2 lnfsreg\2/’ | sh

And to do this as a script:

loghyr:xxx thomas$ more
#! /bin/sh
ls -1 ${1}* | sed ‘s/\(‘${1}’\)\(.*\)/mv \1\2 ‘${2}’\2/’ | sh

Querying Active Directory with Unix LDAP tools.

Tuesday, February 7th, 2012

Querying Active Directory with Unix LDAP tools.

Make Safari remember a password

Monday, January 23rd, 2012

Making a patch set

Monday, June 27th, 2011

Get a clone and make a new branch:

290 21:08 git clone git://
291 21:08 cd cthon04
292 21:08 git branch FreeBSD
293 21:08 git checkout FreeBSD
294 21:08 git branch

Edit your files and commit the changes:

299 21:09 git commit -a

Make the patch set:

303 21:15 git format-patch --cover-letter -s -n master..FreeBSD

Edit the cover letter to document your changes:

309 21:20 vi 0000-cover-letter.patch

Send the changes:

311 21:21 git send-email --smtp-encryption=tls --smtp-user=<user> --smtp-server-port=587 --to "<owner>" 000*

Note, while you might use a different email address inside the cover letter, it will still go out as from the user being referenced above. I.e., use the real smtp-server if you don’t want to expose your gmail account.

Note, you might have to install git-mail to do it this way. You can mail the patch set in many different ways.

Don’t whine about wget on OS X

Friday, March 11th, 2011

OS X: Using curl instead of wget


loghyr:xdr thomas$ wget
-bash: wget: command not found
loghyr:xdr thomas$ curl -L > nfsv2.x
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 49940  100 49940    0     0  97348      0 --:--:-- --:--:-- --:--:--  140k

Wireshark ChmodBPF errors on Snow Leopard

Wednesday, January 26th, 2011

Wireshark ChmodBPF errors on Snow Leopard

Building SlugOS 5.3-beta on Fedora Core 14

Wednesday, December 29th, 2010
  102  yum install help2man
  104  yum install texi2html
  116  yum install glibc-static
  117  vi /kanigix/slugos/5.3/slugos-nslu2be.tmp/work/x86_64-linux/unifdef-native-2.6.18+git-r0/unifdef.c

The last was to change getline() to getline2() to avoid a conflict.

Very nasty one here for this message:

[tdh@wont 5.3]$ more /kanigix/slugos/5.3/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/linux-libc-headers-2.6.23-r3/temp/log.do_configure.13663
NOTE: make -e MAKEFLAGS= allnoconfig ARCH=arm
Makefile:416: *** mixed implicit and normal rules.  Stop.
FATAL: oe_runmake failed

(Note: You could probably build easier against make-3.81 instead of make-3.82 !)

Edit these two files to apply this diff:

[tdh@wont 5.3]$ find . -name Makefile | grep glibc | grep  manual./slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/glibc-initial-2.6.1-r15/glibc-2.6.1/manual/Makefile

And also apply this patch to

[tdh@wont linux-2.6.23]$ diff -u Makefile Makefile.STOCK 
--- Makefile	2010-12-29 18:23:58.176755981 -0600
+++ Makefile.STOCK	2010-12-29 18:21:43.405298124 -0600
@@ -413,11 +413,7 @@
 include $(srctree)/arch/$(ARCH)/Makefile
-config: scripts_basic outputmakefile FORCE
-	$(Q)mkdir -p include/linux include/config
-	$(Q)$(MAKE) $(build)=scripts/kconfig $@
-%config: scripts_basic outputmakefile FORCE
+config %config: scripts_basic outputmakefile FORCE
 	$(Q)mkdir -p include/linux include/config
 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
@@ -1467,10 +1463,7 @@
 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 # Modules
-/: prepare scripts FORCE
-	$(build)=$(build-dir)
-%/: prepare scripts FORCE
+/ %/: prepare scripts FORCE
 %.ko: prepare scripts FORCE

And do the getline2() trick here:


And more:

[tdh@wont busybox-1.13.2]$ pwd
[tdh@wont busybox-1.13.2]$ diff Makefile Makefile.STOCK 
< config: scripts_basic outputmakefile FORCE
< 	$(Q)mkdir -p include
< 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
< 	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
< %config: scripts_basic outputmakefile FORCE
> config %config: scripts_basic outputmakefile FORCE
< /: prepare scripts FORCE
< 	$(build)=$(build-dir)
< %/: prepare scripts FORCE
> / %/: prepare scripts FORCE

Keep on fixing these as you found they broke. Consider again trying make-3.81!

A recursive gdb script for Binary Trees

Thursday, October 21st, 2010

If we have a binary tree, how do we determine if a key is in the tree? Or another way, how do we know it was inserted correctly? We need to visit every node.

This is a recursive problem and hard to do in gdb. The convenience variables are very simple and we can not implement a stack with them. Since they are effectively global, we can not even hide them in stack frames. What we can do is use concatenation and a node-id to generate uniqe names.

Note that you have to do all variable name declarations before you do any recursion. That statement will make sense when you violate it and wonder why your output looks strange.

define indentby
        printf "%*c", $arg0+1, 0

define walk_btree
        set $node_$arg0 = ($arg1)
        set $fnum_$arg0 = ($arg2)
        set $branch_$arg0 = ($arg3)
        set $space_$arg0 = ($arg4)
        set $leftid_$arg0 = $arg0 + 1
        set $rightid_$arg0 = $arg0 + 2

        indentby $space_$arg0
        printf "%d %u (btree *)%p\n", $branch_$arg0, $node_$arg0->e_type[$fnum_$arg0].key, $node_$arg0

        set $space_$arg0 = $space_$arg0 + 1
        if $node_$arg0->e_type[$fnum_$arg0].left
                walk_btree $leftid_$arg0 $node_$arg0->e_type[$fnum_$arg0].left $fnum_$arg0 0 $space_$arg0
        if $node_$arg0->e_type[$fnum_$arg0].right
                walk_btree $rightid_$arg0 $node_$arg0->e_type[$fnum_$arg0].right $fnum_$arg0 1 $space_$arg0
document walk_btree
        Recursively walk the binary tree printing out the key for the fnum'ed entry

define start_walk_btree
        walk_btree 0 $arg0 $arg1 3 1
document start_walk_btree
        NODE FNUM
        Recursively walk the binary tree printing out the key for the fnum'ed entry

Contrast that against a very simple algorithm to find if the key is in the tree (with the assumption the tree is valid).

Recursion is not needed as we lop of a branch with each iteration.

define find_btree
        set $node = $arg0
        set $fnum = $arg1
        set $key = $arg2
        set $process = 1

        while $node && $process
                if $key == $node->e_type[$fnum].key
                        set $process = 0

                        if $key < $node->e_type[$fnum].key
                                $node = $node->e_type[$fnum].left
                                $node = $node->e_type[$fnum].right

        if $node
                printf "Found match on (btree *)%p\n", $node
                printf "No matching node in the binary tree\n"

Using xargs to apply tshark to many capture files

Thursday, October 21st, 2010

pktt on a filer can capture for all network interfaces on a head. In order to quickly determine which have relevant data, we can use xargs:

KinMage:csiqa-6080-15 thomas$ ls -1 *021* | xargs -I {} -t tshark -R nfs -r {}
tshark -R nfs -r e0a_20101021_090354.trc
tshark -R nfs -r e0b_20101021_090354.trc
tshark -R nfs -r e0c_20101021_090354.trc
tshark -R nfs -r e0d_20101021_090354.trc
tshark -R nfs -r e0e_20101021_090354.trc
123   0.267673 -> NFS V4 COMPOUND Reply (Call In 122) <EMPTY> PUTFH;CLOSE
tshark -R nfs -r e0f_20101021_090354.trc
tshark -R nfs -r e4a_20101021_090354.trc
tshark -R nfs -r lo_20101021_090354.trc
tshark -R nfs -r losk_20101021_090354.trc
KinMage:csiqa-6080-15 thomas$ cd ../csiqa-6080-16/
KinMage:csiqa-6080-16 thomas$ ls -1 *021* | xargs -I {} -t tshark -R nfs -r {}
tshark -R nfs -r e0a_20101021_090347.trc
tshark -R nfs -r e0b_20101021_090347.trc
tshark -R nfs -r e0c_20101021_090347.trc
tshark -R nfs -r e0d_20101021_090347.trc
tshark -R nfs -r e4a_20101021_090347.trc
tshark -R nfs -r lo_20101021_090347.trc
tshark -R nfs -r losk_20101021_090347.trc

So we see the first head saw NFS traffic on e0e, but the second saw none.