Thursday, May 17, 2012

Rolling back latest git commit

It's surprising how difficult it's to undo the latest commit you accidentally made in git repository. It's not difficult, but the commands are obscure.

Depending upon the situation you can do one thing or the other.

1. You have already pushed the commit to remote. Then only safe way I know is to do "git revert ". It will create a new commit that essentially negates the effect of the given commit. This will leave two self-cancelling commits in your git history, but it's a safe choice in case you are in doubt.

2. You haven't pushed the commit to remote and you only want to change the message of the last commit or only want to add some more files to the last commit. Then you can run "git commit --amend".

3. You haven't pushed the commit to remote. You can still use "git revert ", but you have another option. You can run "git reset --soft HEAD^". This will undo your last commit and leave the files from that commit in "staged" status. Now if you didn't want some of those files in that commit, you can unstage them.

Before you use any of the above commands however, here's an advice. Git commands are abstruse and coding scenarios vary enormously. My situation may have been different when I used above commands from yours. Some git commands can cause loss of work if not performed correctly (git reset flavors especially). Here is the best way to go about.

Create a temporary directory, do "git init", create some mock files and mock commits. Then try the git commands you are doubtful about. Once assured about what they do is what you want, apply them to your working repository.

Friday, April 20, 2012

Google Lunar X Prize

Came across this long article about how the teams in Google Lunar X Prize are faring so far. It looks like many teams are finding it hard to secure funding for the project and may not make it to the 2015 deadline. Many are dropping out.

After I learnt about the things that these teams will have to achieve in order to claim the prize, I thought the whole thing was unnecessarily over-ambitious.
The $30 million Google Lunar X PRIZE will be awarded to the first privately funded teams to build robots that successfully land on the lunar surface, explore the Moon by moving at least 500 meters (~1/3 of a mile), and return high definition video and imagery
It means the team has to accomplish a number of difficult things like
  1. launching successfully from earth
  2. landing safely on moon 
  3. building a rover that can at least move 1/2 km, autonomously or remotely
  4. communication system with robot for control and video transmission 
  5. robust packaging of the rover during the flight and landing
If the goal of the competition is to further the Space exploration technologies, the prize should have focused only on first two things - launch from earth and land safely on moon. There are other competitions to promote advancement in robotics. Why waste limited funding resources on technologies that are not directly related to Space. They should have limited the scope of the competition to launching a piece of rock from earth and safely landing it on moon. That still would have been a massive achievement in itself.

If a team successfully puts a rover on Moon and fails to drive it, who cares? Driving a robot and recording a video is trivial, compared to landing on moon.

The most important obstacle to space exploration is the exorbitant costs involved in just escaping the gravity well. We need to focus solely on that single portion of the problem first.

Saturday, March 31, 2012

iTunes Download stopped (err =9006)

It's pretty frustrating to see this error in iTunes when you have spent a long time downloading some stuff over a slow network. You hit that re-download button, hoping that it will just immediately mark it alright after it has found the already downloaded content, but it starts the download all over again.



Don't click that re-download icon.

In my case when I saw the above error after the download was complete, I found the files hidden in the iTunes folder. I could copy them elsewhere and open the content in VLC.

The folder you will find it in is
$HOME/Music/iTunes/iTunes Media/*

Sunday, March 18, 2012

Good essay on user centric software design

Came across this long post "#46 – Why software sucks" by Scott Berkun via Hacker news.

It discusses how software developers don't think about software design from their users' point of view and eventually create a product that sucks. There is nothing new in the writeup that I haven't read elsewhere before, but it's well written and it seems to explain the problem quite clearly. Here is a quote that I especially found appealing - it addresses the difference between good code and good product.
One illustration of the philosophical differences between love of construction and love of good things is the belief that code should be beautiful. I’m a fan of beautiful things: the world can use more of them, including more lines of beautiful code. But the trap is that code is an artifact of constructing software. When code is well written (beautiful or homely), it compiles. And it’s the output of the compiler (or browser) that people see. It’s the complied code that changes the world. The beauty of the code is relevant only to people that look at code. To worry about code aesthetics more than the aesthetics of the product itself is akin to a song writer worrying about the aesthetics of the sheet music instead of the quality of the sounds people hear when the band actually plays.
...
Computer science is taught with a construction mentality. Even the theory and philosophy that are covered support construction, not higher level design, or how to make good software in the sense I’ve described. Aspects of design are covered, but at an internal level, the design of object models, data structures and networks, not at the level of what happens when the technology meets the world or the people in it

Sunday, November 27, 2011

Master pieces from screen

A key characteristic of memorable movies/shows is they have a dense storyline.

They tell a lot of things in very short span of time. When you recall individual parts of these stories, they seem a lot bigger by themselves. Over time different plots from the  movie bubble up in your memory and as you review them at your own pace you see the details and angles you missed before. The separate scenes appear much longer in your mind, when they actually take few minutes on screen. After years when you watch the movie again, you feel surprised that all those things happened in the span of mere couple of hours.

A classic example is Godfather. Many times I find it hard to believe that Michael Corleone turns from a soldier to the head of mafia family only in Godfather-I. That scene when he protects his father in hospital, that scene when he fumbles for revolver in restaurant bathroom before making his first kill, his exile in Italy when he gets married first time and subsequently looses her, the scene when Vito Corleone dies while chasing his grandson, the scene when Michael makes an offer to Moe Greene and dominates Fredo, the scene of baptism ceremony with killings of his competitors interspersed. Each one of these scenes makes deep impression in our memories, but only take few minutes on screen.

Recently I had the same experience when I watched first episode of Mad Men again. So many things happen in that first episode. It gives the first glimpse of every character's character. A dialog, a casual comment, a side glance or even a pause tells so much about the character. None of it is unintended. There is great meaning even in non-action, like when Don won't take Pete's extended hand calling him "Buddy". Of course you don't get it the first time. But after you have watched the characters for four seasons and you have known their true natures, you really appreciate how their first appearance in that first episode was thoughtfully composed to give you hints of their attitudes and aptitudes. It must take a master mind to compose and direct such potent work.

I plan to watch the first four seasons of Mad Men again, before the fifth one starts in March next year.