Archive for the ‘Uncategorized’ Category

Setting up and using a git wrapper around SVN with git-svn

Posted on January 27th, 2012 in git, Uncategorized | No Comments »

Note: I wrote this post a long time ago but never got around to posting it. A lot of these steps are applicable to porting an SVN repo to Git as well.

Preface on why I love git

Roughly four years ago I switched to git for version control and it’s changed my development life. While SVN is sufficient to “get the job done” in terms of keeping a history of your commits with a group of people, Git is truly the next evolutionary step up in every way. I could expound a whole article on the joy of git, but many others already have, and this articles not about that. But I will kindly throw in my 0.02 on why I personally love it:

  • It’s fast. Git keeps your whole repo’s history local. So no need to ping your repo server for every command. You can even checkout your codebase from 3 weeks ago or a year ago in under a second.”
  • It works offline. That’s right, no internet. Sync up later.
  • It has useful modern tools. Like git stash and git bisect. Both will save you a lot of time.
  • It’s your third hand. Let’s face it, besides svn being slow, it’s not friendly enough to do more than throw your past commits into an empty hole you will probably never see again. With very little setup, you have beautiful colored output in your logs and diffs with git. And “git log” actually pages by default (while keeping colors) instead of flooding your console with the entire repos history! Want to query something in your history log? What about all commits from your friend Bob in the past 2 weeks?
    git log --date=relative --author=nizam --since="2 weeks ago"

    Bam. Done.

  • Easy repo creation. You don’t have to be an admin to setup a git repo. Just cd into a folder and type “git init”. You just created a new repo. I do this all the time, for example in my folder of todo lists, I use it to track history of my todos. At work someone kept messing up the apache config file, all I had to do was “git init” in /etc/httpd/conf and now I can easily “git diff” new changes that were made and revert / adjust if needed.
  • Many ways to use it. Git is promoted as “decentralized” version control, but it can be an easy drop in replacement for any job SVN can do. Which leads me to…

With all those advantages, many larger companies haven’t jumped on the git bandwagon. I believe there’s two reasons this is the case.

  • As programmers get more experienced, they generally become more pragmatic (which is generally a good thing.) They adopt a “if it ain’t broke, don’t fix it.” mentality. After all, SVN get’s the job done.
  • There is a bit of a learning curve with git. But there are a ton of good resources for learning it. I recommend getting your hands dirty with Git Immersion if you’re new or would like to learn. I don’t recommend wrapping git around svn as I’m about to show you for a person who’s learning git.

Getting down to business.

In order to use git with an svn repo, you’ll have to run some commands to import that svn repo, commit by commit into a git repo.

1. First, make sure you have a version of git installed with svn bindings. If you type “git svn” and it give you an error, I’d google one of the resources in reinstalling git with svn bindings.

2. We need to keep

# In your existing svn repo, lets grab a list of authors
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
# create a new folder
cd ..; mkdir NEWREPO.git;
git svn clone -A ../OLDREPO/authors.txt https://svn/repo/trunk
git svn fetch # this could take a long time as it checks the repo out one rev at a time.
# update your working copy:
git-svn rebase
# commit your changes to svn server
git-svn dcommit

kudos to:

Event-driven programming vs traditional programming

Posted on May 2nd, 2011 in node, Uncategorized | No Comments »

Great post explaining the hype around Node and what exactly is event-driven programming and this business of non-blocking I/O. This kind of system has been around for years (see Python’s Twisted and Ruby’s Event Machine), but never has it been so easy to do with JavaScript’s easy syntax and support for first class functions. As JS dev’s we’re already used to the whole asynchronous mindset of not-blocking the page from the user.

Good series of writeups on Node.js from a developer who’s learning it.

Posted on April 23rd, 2011 in Uncategorized | No Comments »

I did a little experimenting with Node.js back when it initially hit mainstream. I thought it was pretty neat, but haven’t really touched it since considering I didn’t have any upcoming projects that would see major gains using it, didn’t have time for the learning curve, and, honesty, wasn’t sure if Node would stand the test of time.

Fast forward a year later and Node and it’s community has grown a lot. Now that I’m messing around with UglifyJS, it’s about time to get down to learning the roots—I know that even though UglifyJS is written in Node doesn’t necessarily mean that one needs to know it to use this utility, but I’m the kind of guy that needs to know everything (like what is Ugly’s relation to CommonJS) and now’s the best time to continue my exploration than ever.

As a starter, Jan Van Ryswyck of wrote a series of articles on his experience of learning Node, starting from the basics of why use it and what are it’s benefits. Though it’s geared towards Window’s users, it’s still a pretty good read. He goes into the details of the event-driven model of Node (familiar to just about every JS developer), compares it to the traditional thread model, discusses Node’s growing community and open-source plugins, how to debug a Node application, and so on. Here’s a link containing the various chapters: Taking Baby Steps with NodeJS the Towering Inferno.

The iPhone’s one fatal flaw: undependable alarm bug

Posted on February 17th, 2011 in Uncategorized | No Comments »

I sit here, waiting for the 10:07am Caltrain cursing my iPhone for a bug I wish was more well published. It’s something that’s bit me a few times in the past with older iPhones and happens when an unconfirmed popup alert will prevent all alarms from going off – this can be a text message alert, battery-low alert, etc. Today it was a Facebook comment alert that just so happen to popup before my morning alarm. Now I’m late for work. I only have myself to blame (I do set multiple alarm sources but one is the radio). Man is this annoying.

Pretty printing XML with xmllint

Posted on December 10th, 2010 in Uncategorized | No Comments »

Today I was debugging some long XML responses and I went online to find a pretty printer so that I could read them easier. A quick Google search turns up a decent XML beautifier:

Unfortunately one XML response in particular was over 200kb which choked the above parser. I searched for 5-minutes and couldn’t find another one that didn’t require downloading and setting up. My next bet was to ask the geniuses in the irc #emacs channel if this is something emacs might do and got a quick answer: Use xmllint.

I did a quick check if I have this program with which xmllint on both my OS X machine and my remote Centos server – sure enough it was there. Here’s how to use it:

Just dump your xml in a text file (xml.txt) and run the following:

xmllint -format xml.txt --output xml2.txt

Additionally, if you’re a TextMate user you can just go to BUNDLE > XML > Tidy.