The Buffer Kool Aid

I’ve already drank the emacs kool aid, but today something has finally dropped: I now understand what Steve Yegge means in his famous “effective emacs” essay:

There is nothing else quite like the Emacs buffer experience in all of application-dom. Once you realize how consistent and powerful this model is, all other applications become slightly distasteful, because you know their UI is just getting in your way.

this little (and important IMO) realization came to me when I was trying to display the output of a clearcase man command and realized I can issue:
M-x shell-command and feed cleartool man rmview and get a standard emacs buffer in return, which in turn means all my default key bindings and buffer tricks will just work.

This is important. In the same sense that ‘everything is a file’ makes a powerful abstraction that in turn makes the tools that operates on a file used on a wide variety of objects, ‘everything is a buffer’ offers the same powerful abstractions to UIs.
too bad the modern UI interfaces turned away from this metaphor twenty years ago.

Posted in emacs, foss | Tagged , , | Leave a comment

OSX and Windows XP: The Quest For Synergy

Part I – The Synergetic Way

Synergy is high there on the list of software I don’t know how I could have been productive without. There is one huge obvious elephant in the room when it comes to Synergy, though: the security model, or lack of one really. Not only that every key press travels in clear text over the network it does not even authenticate clients nor servers.

Bottom line there is no security to talk about: Synergy is one big flying security vulnerability. Lucky me: there are ways to add an after-thought security to a deployed solution.

But first allow me to spell out my motivation: as usual I’m trying to make the technology work just like I want it to. See I carry work home and I carry it in a form of a Laptop running windows. I also have a MacBook Pro as my primary system at home connected to a 24″ Dell UltraSharp 24FPW hooked up via a DVI, I’d like my Windows Laptop to be connected to the VGA port on the same monitor so I could use the 24″ screen real estate to do some work. Now I’d like to do that such that all I need to do is dock my Windows XP and use my existing Mouse, Keyboard and obviously the monitor. When I disconnect the XP Laptop I would like to just undock it shove it to my bag and go without hassle and leaving my MacBook fully connected. The XP Laptop is connecting to the network via my home wireless network – so some encryption/authentication would not be a bad idea. I could have spare the effort and fall back to use Cord but the VPN software I use just refuses to authenticate when I just remote in, besides why push all those pixels via the network when I can be connected directly via VGA?

So I’ve decided to use synergy to control the XP mouse when my Mac is serving as a synergy server and tunnel this via stunnel. Now all I have to do in order to use the XP Laptop is: dock it, press the power button ( wake it up) and then switch inputs by pressing a button at the front of the monitor .
A couple of gotcha I’ve hit even before getting to the stunnel part:

When testing synergy I’ve hit a problem where if the machine would auto-lock I wouldn’t be able to get to feed a password in to log. ctrl-alt-del had no effect.

examining the logs I’ve noticed the following error:
DEBUG: emulating ctrl+alt+del press
DEBUG: can't open Winlogon desk: 5

to make a long story short it turns out that under windows NT and descendants the screen saver and the login windows are running under a different desktop each,
Here’s what MSDN has to say:

By default, there are three desktops in the interactive window station: Default, ScreenSaver, and Winlogon.

The only way Synergy is able to interact with the Winlogon Desktop is if it runs as a systems service. This means that under windows when configuring Synergy’s Auto Start one has to choose to have “synergy start automatically when the computer does”
. If the synergy server restarts this means for whatever reason that the client will loose access to the Winlogon Desktop.
So there shouldn’t be any problem to login if synergy runs as a system service and the synergy client is not restarted, the ctrl-alt-del combination should just work.
However if the screensaver kicks in I’m unable to dismiss it with synergy driven input device, this is something that I have not yet found a direct solution to.
I did, however found a workaround.

Later I also discovered that the synergy server running on the OSX must run as root.

Another Issue I have seen is what I had to call ‘alt-key at half-duplex’,

I’ve tried to solicit some help from superusers , here is an extract of the longish description:

the alt key does not function as a modifier at all by that I mean: if to use notepad as an example:

If I press alt and release it then the first menu item gets highlighted and I can press ‘f’ and get the file menu (this is a normal behavior). However if I’m holding down alt and then simultaneously press ‘f’ I get the first menu item highlighted. this is not a normal effect of this key combination, with a properly functioning alt key the file menu would have been displayed.

It turns out this is easily solvable by upgrading to the Mac OSX beta version (1.5) of synergy server.

Here is the synergy.conf I’m using on the server:

   section: screens
       mcradles-macbook-pro.local:
       mcradleXP:
    end

     section: aliases
        mcradles-macbook-pro.local:
                computer.home
                192.168.6.2
    end

    section: links
       mcradles-macbook-pro.local:
           right = mcradleXP
       mcradleXP:
           left = mcradles-macbook-pro.local
    end

In the next post I’ll start covering the security aspect and how to tunnel synergy via stunnel.

Posted in foss, open source, OSX, productivity tools, remote, sync, Technology | Tagged , , , , , , | Leave a comment

CoRD And Swapped Mouse Buttons: The Freedom To Be Particular

A few years ago I’ve swapped between my mouse’s right and left buttons n my XP laptop, this was due to a sports injury that I have long recovered from since, I however kept the mouse button swapped.
Even when setting up a new system much more recently I still set it up with the mouse buttons swapped.
partly because the mouse was already to the left of the keyboard, also known as sheer laziness but partly also because I enjoy the feeling of being able to get accustomed to a change,
and partly because I think it makes me use the mouse less and hence forces me to learn more keyboard shortcuts (not that my extensive and expending Emacs usage is not driving me in that direction anyway)

On the other hand at home my MacBook mouse buttons are not reversed.

It all nice and cozy until I try to use CoRD to remotely connect from my MacBook to my XP – then I have to remember to right click when I want to left click and vice versa and it’s very confusing,
I can operate a mouse with the buttons swapped (obviously: I do it every weekday) but it becomes natural to me only if it’s on the left of the keyboard.

So this brought me to a Stallman-esk moment where I had a piece of software that was generally functional but I had to extend it in a quirky way that is unique to me (and presumably of no interest to software owners),
luckily enough CoRD is an open source software and it took me under 30 minutes to hack it such that it will send a left button indication instead of right button and vice versa.

technically I just had to

1. get the source

svn co https://cord.svn.sourceforge.net/svnroot/cord/trunk CoRD

piece of cake.

2. find where the buttons are handled.

sort of piece of cake.
Now since this fix is so unique to me and my bizarre preferences that I don’t expect it to be useful enough to be worth even sending a patch back,
if anything it will clutter up the code or even worse the GUI (not that I expect anybody to actually accept such a fix let alone install it in the GUI),
since all of the above it became clear to me it’s not worthwhile looking for solutions that will fit elegantly in CoRD as a whole therefore I allowed myself to hack a solution: (in the preliminary meaning of the word ‘hacking’)
I just swapped the values of button 1 and button 2 in “constant.h” as follows:

/* mcradle hack: swap buttons to support reversed buttons on xp server

#define MOUSE_FLAG_BUTTON1 0x1000
#define MOUSE_FLAG_BUTTON2 0x2000
*/
#define MOUSE_FLAG_BUTTON1 0x2000
#define MOUSE_FLAG_BUTTON2 0x1000

3. compile and serve over a bed of lettuce

It took me longer to write this post to describe what I’ve done than it took me to actually modify the whole thing,
It made me think about our collective use of technology: as more and more software is involved we are able to tweak technology to
better fit our needs rather than to get used to how the technology was designed to begin with,
and for programmers it make sense to get out of their way to use open source software over proprietary one every time, because they *have the ability* to tweak stuff. (and even learn a trick or two along the way)
I’m still debating my (Philosophical, if you will) position on software and freedom but from pure practical stand point if I would to use a Microsoft close source client I just would have had to live with the way it works, like it or not.

Posted in "software enginerring", CoRD, open source, OSX, productivity tools, remote | Tagged , , , , | Leave a comment

Git, The Kernel And Extenral Drivers: Look Ma I Can Version Magic

I was just compiling a module I’ve been given outside the kernel source tree
got an error trying to load it:


version magic '2.6.x.y-7aac9b1d2 mod_unload' should be '2.6.x.y mod_unload'

Weird — as I’m compiling it against the same source tree that the kernel was built from
And then I realized: the appended string is a lot like a git hash! (hey not all hexadecimal strings are alike!)

turns out that if you have CONFIG_LOCALVERSION_AUTO turned on in your .config and if the kernel you’re compiling is detected to be git controlled the resulting binary will have it’s version magic string appended with the git current hash.

and now I know that this also applies to modules you compile against a kernel tree like this which are governed by a git repo.

good to know.

Posted in "software enginerring", Drivers, Kernel, source control | Tagged , , , | Leave a comment

Wifi roaming on the blackberry

here’s a problem I have with my blackberry that was not annoying enough to encourage me to research until now:it will not automatically connect to a wifi access point.
I can find and setup a wifi network just fine and have already setup one for my home AP one for the work AP even one AP for my favorite bar (that I have not yet visited ever since).

However I had to manually navigate every morning at work and every evening at home to the wifi menu in my blackberry and change the active AP profile.

needless to say that I have under utilized the cost saving that wifi is by frequently forgetting to switch APs.

turns out it’s real easy to cure: just had to navigate to ‘Wi-Fi Options’ and uncheck ‘Enable single profile scanning’.

That’s it — free bandwidth here I come.

Posted in productivity tools, remote, Uncategorized, woraround | Tagged , , , | Leave a comment

Guru Meditation: VirtualBox and Commodore 64

Just got this error "Guru Meditation -2701 (VERR_VMM_RING0_ASSERTION)" on my virtualbox-ose 3.2.8 hosting windows 7 on my Ubuntu 10.04.1 machine.

Looking around for the error it turns out that the error text itself is a homage to an old Amiga system error which reminded me of the book “On the Edge: the Spectacular Rise and Fall of Commodore” I’ve read last year.

I’ve taken all my first steps in the computing world (except maybe using a modem and a BBS) as a teenager on my Commodore 64 which included: gaming, basic programming, assembler programming ,machine language programming and very first steps in digital music composing.

Reading the Narrative that brought together this marvelous magical machine that thought me so much of what I know and like today was absolutely facilitating and beyond, having learned what random marketing and social interaction influenced choice and shaped the technology world as we know it today was mind opening as well as telling that history is not only shaped by inventors and geniuses but also to a varied degree by petty rivalries and personal grudges.

At point it seems that the narrative is slightly biased towards the engineers perspective of things but I’ll be the last to complain about that, between the competing narratives I would much rather hear the engineers and the designers side.

I found the book to be a real page turner and informative at the same time as the engineering drama unfolds.

Incidentally after I’ve hit the said Guro Meditation bug trying to start VirtualBox again by issuing:

vboxheadless -startvm windows7

Resulted with the following error in the VirtualBox log (if you’re looking for it note that it is not created by default under /var/log but rather in the running user home directory)

PDM: Failed to construct 'e1000'/0! VERR_SUPDRV_INTERFACE_NOT_SUPPORTED (-3701) - The component factories do not support the requested interface.

This was cured by reloading the drivers as follows:

sudo modprobe -r vboxnetflt
sudo modprobe -r vboxnetadp
sudo modprobe -r vboxdrv
sudo modprobe vboxdrv
sudo modprobe vboxnetadp
sudo modprobe vboxnetflt

Posted in book review, Command Line, open source, productivity tools, woraround | Tagged , , , , , , , , , | Leave a comment

Tarball as a remote git repo

I have two computers that do not share a network link, let’s say for simplicity sake that one of the machines is disconnected. I however do want to share my ever growing .emacs.d directory of emacs-lisp goodness.
Since the emacs configuration is actually code the obvious choice is to use source control management software to keep it in sync and among the newer SCMs I’m most familiar with Git.
Ideally I wanted to mimic the way git works but without a network, that is I wanted to be able to simply push my changes by issuing a simple enough command.
I came across this article which suggests to create a remote repo on a usb thumb drive and push and pull from it. It’s a very good idea and I’ve used it a couple of times.

However due to the relatively long period between my synchronization sessions I had to refer back to the article to remind myself of the steps, which after a few times made me want to script the process.

Having sat down to plan the automation it occurred to me that what I really wanted is to have the ability to dump to a tarball and update from a tarball as if that was a real repo, I didn’t want to be looking for that last thumb drive that I’ve created the ‘remote’ repo on.

So my requirements became simple: create a sync-object which I’ll be able to serialize and de-serialize myself in any way,  independently from the script and once de-serialized allow update an older repo from, and then dispose of the object. coming to think of it this is really like a ‘patch’ for a git repo.

Below is the script I came up with, the usage, I believe is quite straight forward:
to create an update object called dotemacs.osx.tgz I type the following:
git-tarball.sh push ~/dotemacs.osx.tgz

to update an existing git repo from dotemacs.osx.tgz I type:
git-tarball.sh pull ~/sync/dotemacs.osx.tgz

#!/bin/bash

execute_commands=1
trace_commands=1

function run_cmd ()
{
    cmd=$1

    if [ $trace_commands -eq 1 ]
        then
        echo "run: $cmd"
    fi

    if [ $execute_commands -eq 1 ]
        then
        $cmd
    fi
}
function push_to_repo ()
{

        if [ "$#" -lt 1 ]
            then die "1 arguments required, $# provided (type git remote for a list of repos)"
        fi
        run_cmd "git push $1"

        # trickery to find the repo dir based on the repo name
        # git remote shows a list that needs reducing there are two entries per repo
        # as follows
        # osxproxy      file:///foo/temp/remote_repo/dotemacs/ (fetch)
        # osxproxy      file:///foo/temp/remote_repo/dotemacs/ (push)
        # the grep -m 1 (max count) reduces the list to the first enrty
        # awk uses the second field where space is the field seperator
        # and finally sed removed the 'file://' prefix

        REPO_PATH=`git remote -v | grep -m 1 $1 | awk '{print $2}' | sed -e 's!file://!!1'`
        #remove the trailing slash
        REPO_NAME=`echo $REPO_PATH | sed -e 's!/$!!'`

        D_NAME=`dirname $REPO_PATH`
        B_NAME=`basename $REPO_PATH`
        PREV_DIR=`pwd`
        #tarball the bastard
        #first get out of the way any old copies
        REPO_DIR=`dirname $REPO_PATH`
        # echo "repo is $REPO_PATH and dir is $REPO_DIR"
        run_cmd "mv $REPO_NAME.tgz $REPO_NAME.renamed.at.$(date +%Y%m%d).tgz"

        run_cmd "cd $D_NAME"
        run_cmd "tar -czf ./$B_NAME.tgz ./$B_NAME"
        run_cmd "cd $PREV_DIR"

        #copy the file to the given path
        if [ "$#" -eq 2 ]
            then
            run_cmd "cp $REPO_NAME.tgz $2"
        fi

}
function pull_from_repo ()
{
        repo_name=$1
        run_cmd "git pull $repo_name master"
}
function create_repo ()
{
        REMOTE_REPO_NAME=$1

        if [ "$#" -eq 2 ]
        then
            REMOTE_REPO_DIR=$2
        else
            REMOTE_REPO_DIR="/mcradle/temp/remote_repo/$1_$(date +%Y%m%d)/"
            #echo "remote repo dir is $REMOTE_REPO_DIR"
        fi
        REMOTE_REPO_GIT_DIR="$REMOTE_REPO_DIR$REMOTE_REPO_NAME.git"
        run_cmd "mkdir $REMOTE_REPO_DIR"
        run_cmd "mkdir $REMOTE_REPO_GIT_DIR"
        run_cmd "git clone --local --bare --no-hardlinks . $REMOTE_REPO_GIT_DIR"
        run_cmd "git remote add $REMOTE_REPO_NAME $REMOTE_REPO_GIT_DIR"
        run_cmd "git push $REMOTE_REPO_NAME master"
}
function destory_repo ()
{
      REMOTE_REPO_NAME=$1
        run_cmd "git remote rm $REMOTE_REPO_NAME"
}
function push_to_tarball ()
{
    temp_dir="/tmp/$(basename $0).$$.tmp/"
    run_cmd "mkdir $temp_dir"
    #repo_name="autopush_$(date +%Y%m%d_%H%M)"
    repo_name="autopush_$(date +%Y%m%d)"
    copy_to=$1
    create_repo $repo_name $temp_dir
    push_to_repo $repo_name $copy_to
    destory_repo $repo_name
    run_cmd "rm -rf $temp_dir"
}
function pull_from_tarball ()
{
    #this expects a tarball as a paramter
    TARBALL=`readlink -f $1`
    temp_dir="/tmp/$(basename $0).$$.tmp/"
    prev_dir=`pwd`
    repo_name="autopull_$(date +%Y%m%d)"
    run_cmd "mkdir $temp_dir"
    run_cmd "cd $temp_dir"
    run_cmd "tar -xzf $TARBALL"
    repo_file=`readlink -f *.git`
    repo_file="file://$repo_file/"
    run_cmd "cd $prev_dir"
    run_cmd "git remote add $repo_name $repo_file"
    pull_from_repo $repo_name
    destory_repo $repo_name
    run_cmd "rm -rf $temp_dir"
}

if [ "$#" -lt 2 ]
then die "2 arguments required, $# provided."
fi

case "$1" in
push)

        push_to_tarball $2
        exit 0
        ;;

pull)
        pull_from_tarball $2
        exit 0
        ;;
*)
        echo "Usage: cd to the same dir where the .git directory is and type $0 {push new_tarball|pull existing_t\
arball}"
        exit 1
        ;;
esac

exit 0

comments:

  1. It needs a little bit of cleaning up, there are left-overs of experiments I did before landing on the design which makes it over complicated, need consistency when it comes to variable names (case for one)
  2. I don’t understand the effects of creating a new remote repo every sync and then destroying it, don’t know what it takes down with it and if git can handle many of these joining and leaving the repo.
  3. It works for me, and is fast and cool
  4. If had to do it all over I probably would have used python.
  5. This Is sunny side up, error checking could be useful
Posted in open source, remote, source control, sync, Technology, Uncategorized | Tagged , , , , , , | Leave a comment