git stashing & branching

Just discovered something useful today.

Workflow:
– I am working on something on my “master” branch
– I need to update master with some new stuff from a remote.
– I don’t want to mess up with my current changes

Here is the best way to do it in my opinion (works with git 1.6 and above).

git stash save "some stash name"
git stash branch stash@{0} # assuming you only have one stash, otherwise git stash list to know the exact index

You changes should end up in the new branch and you can checkout your master branch to get the new changes from the remote repository.

Convention over configuration over convention

Convention makes everything easy and smooth (Rails, …). Configuration is long, tedious and painful and . Documentation is great and necessary in both cases.
However, I favor Configuration with a set of defaults to magic conventions that are supposed to make my life easy. There are many reasons to this but the main is: “I do not want your thing to get in my way”.

Using git-stash with a branch

You’re working on something on master but you want your changes to be transfered to a branch

Do this:

[17:44:40][akadri@kryptonite:~/Projects/myproject]$ git stash save "message"
Saved working directory and index state On master: stash message
HEAD is now at 821a965 commit message

You can list your stash with:

[17:48:09][akadri@kryptonite:~/Projects/myproject]$ git stash list
stash@{0}: On master: stash message

Now you transfer your changes to a new branch of your choosing and checkout that branch with:

[17:51:54][akadri@kryptonite:~/Projects/Wikipedia]$ git stash branch mybranch stash@{0}
Switched to a new branch 'mybranch'

That’s it!

vim tips

These three lines in ~/.vimrc just changed my life!


let g:netrw_preview = 1
let g:netrw_liststyle = 3
let g:netrw_winsize = 30

and then :Explore works the way it should! Just type “p” to open a file in the preview window and bd or bw to delete a buffer (which doesn’t close the preview window and that’s what I like about it!). Ctrl-W-W to switch between Tree selection and preview window.

:help explore to learn more

The help file is pretty cryptic but it actually helps!

PhoneGap Bada

These past two months I’ve been working on porting the PhoneGap mobile framework to the Samsung Bada platform at Nitobi. The Bada SDK is in C++ and I hadn’t touched C++ in years. It was nice to come back to a compiled language tough after years writing scripting/interpreted languages such as Python/Ruby/PHP or Java.

So far everything is pretty much working except Media and File Handlers. Samsung was kind enough to send me a Wave GT-8500 to test with. Details on how I implemented the thing are available on my nitobi blog.

The source is available on github

It is under MIT License

Check it out and share your thoughts/comments!

Vim Search/Replace/Increment

let’s say you have this in a text file:

item
item
item

and you want to change it to this

ordered_item_1
ordered_item_2
ordered_item_3

You can do this in VIM with the following command:

let i=1|g/item/s//\=”ordered_item_”.i/|let i=i+1

You can do it even more easily using AWK but VIM forever!

Keep a task running

so you’ve got task that you want to run but you need to leave right away and you have to logout.

If you do a “command &” it will certainly run and in the background but if you logout it’ll go away. So how can you keep it running ?
With the “nohup(1)” utility. Preceed your command with nohup and end it with “ampersand &” and it will detach it from the current tty and spits the output to ‘nohup.out” in the current directory.
You can also apply this if you want to run some program and don’t want to daemonize it just yet.

This thing helped me twice in the past few days so I bet it will help you too!

Touchscreen smartphones

It’s been a while I have not posted anything on this blog. I am going to talk about smartphones and the hype that surrounds them. It looks like their popularity is picking up and everybody seems to want some kind of smartphone and especially the Apple iPhone. Apple iPhone is such a trend that some people confuse every existing touchscreen smartphone for an iPhone. Now what is so special about them ? Why are they so popular ?

A lot of people think simplicity and ease of use is the source of the iPhone’s success. The iPhone does simple things but does them better than anything out there. This might be true and for using it for about a week I can attest of that fact. Bu there are so many things that makes me not want to use this device as an everyday phone:

  1. They lock down everything: Not allowed to install third-party apps not approved by Apple, not allowed to run apps in the background (except Apple’s own apps), not allowed to run different apps at the same time, forces you to use iTunes to manage your music, not even allowed to transfer your contacts from/to your SIM card…
  2. The touch screen: I don’t think it’s natural to not get any feedback when they perform a given action. That is especially true for keyboards. I feel faster with T9 than with Apple iPhone’s onscreen keyboard. I make so many mistakes, It is so frustrating! I hear people get better at it but I don’t want to adapt to it. I think it should adapt to me since it’s supposed to make my life easier!
  3. The hardware is not even that great: They advertise the camera of the iPhone 3GS as supporting video recording. That has been supported in regular phones for years and that is just an example.
  4. So what are they so popular ? Is it really simplicity ? Yes but the real answer is: Marketing/Advertising.
    Apple is very good at that. They are the second biggest technology advertiser just behind Microsoft and ahead of IBM and HP that have three time’s Apple’s annual sales (according to NYT). Their ads are usually targeted and sarcastic. we-do-it-better-than-the-others. They spend hundred millions every year.

    One other reason is design: They are also very good at that. It does not need to have a lot under the hood but it’s got to be shiny! People should look at it and think of how beautiful it looks. “IT” can be anything (Computer, Music Player, Phone…).

    So all in all what is it ? A “gadget”! A “toy” ! I don’t see professional people nor power users switching to this thing in the future. What are the alternatives ? There are a lot !

    Their current market share is high but it’s not growing as much as it used to. I think/hope in the end Apple victims will wake up and switch to something else.