Finally starting to get git, at 1% at least

I work on a project on both my desktop and laptop. Each one tracks remote origin, but sometimes I do work on my desktop and want to continue it on my laptop.

So, here goes. This might be totally bogus, but it appears to work. Maybe some git-gurus can improve?

Lets setup my laptop add my desktop as a remote

  git remote add desktop ssh://desktop/path/to/repo

Now lets do some work on my desktop:

  git checkout -t -b mybranch origin/master
  ... do some stuff ...
  git commit

Then lets say on my laptop I want to continue that work.

  git pull
  git -t -b mybranch remotes/desktop/mybranch
  ... do some stuff ...
  git commit
  git push desktop

Woot, now I’ve done work on my laptop, and pushed it back to my desktop. All without pushing back to origin/master (which sometimes I do not want to do!)

macports: git-upload-pack: command not found

When doing a git clone from a repo hosted on a Mac OSX machine (installed using macports), I get this error on the client (Linux, cygwin, whatever):

git-upload-pack: command not found
Solution is to do this on the OSX machine:

cd /usr/bin
sudo ln -s /opt/local/bin/git* .

Blatently stolen from this guy:

Also, better git macports install

But with XCode 4, who needs it?

sudo port install git-core +svn +doc +bash_completion +gitweb

Git bash prompt

This is super useful:

export PS1="\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]$\[\033[00m\] "

Stolen from here:

And this is even more useful! This shows the dirty non/dirty state too!

function parse_git_dirty {
  [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty)\)/"

export PS1="\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\$(parse_git_branch)\[\033[37m\]$\[\033[00m\] "

Stolen and modified from here:

Goodbye, AOL

After 7 exciting years at AOL, I’m moving on, leaving behind some awesome people and great products. As part of my spring cleaning, I’ve decided to clean up That means putting up a blog. Now, I’m a terrible blogger. I can’t write well, and I don’t have that much to say. So, this is going to mostly be a repository of interesting code snippets that I come up with.

I’ve solved so many interesting problems after finding a blog post with a solution to a problem. It probably makes more sense to put this on stack overflow, but I wanted to have a place to drop any thoughts too — should I have any 😉

this is a test of really long posts

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur posuere pellentesque faucibus. Pellentesque nec turpis diam, eget dapibus lectus. In hac habitasse platea dictumst. Phasellus nunc leo, convallis id iaculis eget, fermentum id tellus. Phasellus posuere, diam sit amet luctus rhoncus, turpis tellus bibendum orci, vitae molestie massa mi in nulla. Duis imperdiet aliquam eros ac placerat. Fusce at diam odio. Curabitur sed nibh sed orci consequat rhoncus. Pellentesque pellentesque est id dui tristique aliquet. Curabitur at placerat nisi. Maecenas sed lorem sem, vel rhoncus eros. Donec nec dignissim lectus.

Continue reading “this is a test of really long posts”

What’s this blog for?

I’ve tried to blog before, and it never really works for me.  I just don’t have enough interesting things to say.  I do, however, occasionally run into solutions to problems that I want to save somewhere.  Since I find so much help searching Google for others peoples solutions, I figured I should do the same.

So here’s my first try. How do you get XStream to act sanely when it comes to parsing generally unknown xml files? You override the wrapMapper and tell it to not freak out if a parameter isn’t found…

   static XStream xstream = new XStream() {
      protected MapperWrapper wrapMapper(MapperWrapper next) {
        return new MapperWrapper(next) {
          public boolean shouldSerializeMember(Class definedIn,
                  String fieldName) {
            if (definedIn == Object.class) {
              return false;
            return super.shouldSerializeMember(definedIn, fieldName);
    static {
       xstream.alias("xml-read-devices", UdrXmlReadDevices.class);
       xstream.alias("xml-write-device", UdrXmlWriteDevice.class);
       xstream.alias("xml-confirm-confcode-device", UdrXmlConfirmConfCodeDevice.class);
       xstream.addImplicitCollection(UdrXmlReadDevices.class, "device", UdrDevice.class);
       xstream.addImplicitCollection(UdrServices.class, "service", UdrService.class);
       xstream.useAttributeFor(UdrService.class, "flags");
       xstream.useAttributeFor(UdrService.class, "serviceId");
       xstream.useAttributeFor(UdrService.class, "type");
       xstream.useAttributeFor(UdrXmlConfirmConfCodeDevice.class, "errorCode");
       xstream.useAttributeFor(UdrXmlWriteDevice.class, "errorCode");