Someone at work pointed out a cool utility called tsocks.

tsocks allows non-SOCKS-aware applications (e.g.: telnet, ssh, ftp, etc.) to use SOCKS without any modification. It does this by intercepting the calls that applications make (i.e.: through LD_PRELOAD) to establish network connections and negotating them through a SOCKS server as necessary.

Installing it on a Debian-based system is as easy as:

$ sudo apt-get install tsocks

I then edited my /etc/tsocks.conf file to have this:

local =
local =

server =
server_type = 4
server_port = 1080

The last part is the most important part and is basically telling tsocks that it’s going to proxy all of my connections through a SOCKS 4 proxy at localhost:1080 (this SOCKS proxy comes from the fact that I have a “DynamicForward 1080” line in my ~/.ssh/config for the ssh proxy that I use to connect to work).

Then I can access machines behind the corporate firewall by invoking tsocks in “one-off” fashion like this:

$ tsocks ssh somehost.firewalleddomain.net

or if typing “tsocks” in front of each of your commands is too much trouble, tsocks can be turned on and off semi-permanently so you can do stuff like this:

$ source /usr/bin/tsocks on
$ ssh host1.firewalleddomain.net
$ ssh host2.firewalleddomain.net
$ source /usr/bin/tsocks off

Neat concept. Interesting use of LD_PRELOAD.

Ordered glasses

It’s been a few years since I lost my pair of glasses so I decided it’s time to get new ones, primarily for driving at night, as they make distant signs sharper (I have a pretty mild case of myopia).

I went ahead and got the more expensive Calvin Kleins because hey, in a few months I won’t miss the extra money I paid. I got the polycarbonate lenses with an anti-glare coating and also got a pair of sunglass clip-ons, which should be nice for daytime driving.

They should arrive in around 10 days.

One annoying thing about Mac OS X…

is that although it has this great UNIX base that people always talk about (and which I appreciate much of the time), they didn’t use the ubiquitous ELF and instead went with a proprietary object format called Mach-O

This means that dynamic linking works totally differently and so you can’t use a lot of mainstays like LD_PRELOAD (analogue is DYLD\_INSERT\_LIBRARIES) and the ldd command (analogue is otool -L). I’ve run headlong into these differences this morning as I’m attempting to port tsocks to Mac OS X. Check out Thomas Strömberg’s post – he’s working through some of these issues too. Another resource: http://www.kernelthread.com/mac/apme/library/

It took me a fair amount of web searching to find out the magic incantation to create an initialization function for a dynamic shared library (that is, a function that gets called when the dynamic library is loaded):

void _init(void) \_\_attribute\_\_ ((constructor));

Note that the word “constructor” in this context has nothing to do with C++ or objects at all. This is just Apple’s bizarrely-named gcc extension for creating initialization functions. I think I might’ve preferred their older, deprecated syntax: #pragma CALL\_ON\_LOAD \_init. Is it just me or does the former syntax seem more aptly named? Where did I find this? See Apple’s Tech Note on the subject, which took me too long to find.

The thing that I’ve always hated about Windows programming is how Microsoft tends to put in platform-specific stuff. I’m now realizing that Apple is guilty of the same thing, although perhaps less so than Microsoft.

The good part about Mach-O is that it supports universal binaries which have both PowerPC and Intel code, which should ease the transition to the new Intel-based Macs.

Lego Mindstorms motor problems

Damn. I guess I’ll try lubricating it with 3-in-1 oil as my friend Todd suggested, but it’s quite likely that I’m going to need to buy new motors.


I posted this to lugnet.robotics.rcx.legos:

My robot is having a hard time getting around and I think that it’s because the
motors seem to be sticking. Even on my linoleum floor, my little tank robot
often gets stuck and goes in slow circles, because one motor gets stuck. Once I
nudge it or pick the robot up, the motor kicks in again but only for a little
while and then gets stuck again a few seconds later.

I am thinking that the motors need lubrication. Is this a good idea and if so,
what type of lubrication to use? I have WD-40 and Tri-Flow, a teflon-based
lubricant that is used for bikes, skates, etc.

Would either of these work and not damage the motor?

and I got the following response:

You may want to check if your motors are the new type 9V geared motor (#43362).

If so, please be aware it is prone to failure, the first sign being sticking. Pl
see my previous post on this ailment:

No amount of lubrication is going to help. In due course the motor will become
permanently stuck and useless. Such is the natural history.

C S Soh

LEGO Mindstorms Robotic Invention 2.0