Akash Manohar blog / projects
25 May 2012

I just found out how to indent multiple lines in Vim. Use = at the line where you want to start the auto-indentation. Then move to the line where you want to auto-indent until.

Example: if you are in normal mode, and want to indent the current line and the next 2 lines, you would do =, then 2j.

To auto-indent the full file, and you were at the top of the file, you could do =G.

You can also select the lines in visual mode and then use =, but that might require a few more keystrokes.

12 May 2012

I’ve been using pry for a while and I’ve always been curious about it. So to see how debuggers work, I tried writing the simplest debugger in Ruby. Thanks to the vast number of rubygems out there, it sums upto just 6 lines.

require 'ripl'
class Binding
  def take_a_look
    Ripl.start :binding => self
  end
end

Now if you want to debug some program, just drop the following line and it’ll fire up a REPL when the interpreter reaches that line.

binding.take_a_look

This is done with the help of the binding method in ruby which returns the current scope, in the form of an object of the Binding class. That one method is what is responsible for the magic. The ripl gem provides a REPL, that you can pass a binding object to, so that the REPL’s scope is the binding you pass.

If you are curious and want to give this a try, install the gem take-a-look. I’ve aliased Binding#take_a_look to Binding#peep, because I felt take_a_look was too lengthy for a debugging method name.

The source is here - http://github.com/HashNuke/take-a-look

11 May 2012

This blog is now powered by Jekyll and Github pages. I’ve ported some posts from my previous blog. After a dozen free services I’ve adored shutdown, I’ve got no hope for any service out there that isn’t charging me for using the service.

“I can haz my own theme. I can haz my own posts. I can haz my blog”

05 May 2012

There are a lot of services that come as go these days. Putting it in Robert Frost’s style,

  "Services may come and services may go,
  But users may go on forever"

Some services get bought when larger companies go shopping and may become many things, sometimes even dead. Some others just shut shop when their time is up. I have very high respect for people running services (useful or fun) that put a smile on peoples faces. When they get bought they make some cash - maybe just enough to get compensated for the time spent. Good for them. But the other side of the story: the people running these services know that

  • there are users who may miss your service
  • these users will miss their data even more

I don’t see these people doing much about it, other than just saying “You can download your data”. But that doesn’t discount the fact that these users spent their time entering data to your system. What do I do with the data. Data is useless without something to that operates on it.

Make sure that all data is portable

APIs, exporters, do what you can to help the users out.

Minimize friction while moving to competitors

Try to partner with your competitors and help them with integrating your APIs to import data. Minimize friction so that users who want to move, are able to do it without much pain. Ideally, buttons that say “click to move to Service-X” would be very pleasant. I’m sure a lot of your competitors will be happy to help you out with this.

Royal farewell

It’s very likely that you launched with beta period and flaunted your invites. When you shut shop, give users the same level of royal treatment. Shut down slowly but provide proper support. This is the period that your support has to be super-active and very helpful. They trusted you and your team when you launched, now it’s time to give back.

Before you turn off the lights, make sure EVERYBODY is gone

In India, when your guests are leaving, it’s considered bad/arrogant to close the door, when the guests are still just outside your door. So you’ll usually notice that Indian hosts wait until their guests are out of their sight before their close their door. I consider users my guests, so they get the same respect.

If you are running a service, that you aren’t sure you’ll be running for a long time, call it what it is - an experiment.

04 May 2012

When people find themselves in situations when nothing seems to make it possible to get the expected result. Some quit and some others force themselves to find a solution. It may be due to deadlines. And it may also be what happens, when something is turned into a Fashion contest.

I feel it’s very wrong to be imposing deadlines for such tasks. These tasks are mostly of creative type. It’s very difficult to come up with an optimal solution under pressure. It may seem to work at first. But when I do it for a long time, I risk losing focus. I might be staring at that very solution and not realize it. I’ve lost the motivation to dig deeper, because I am not going to be shipping that cool idea anytime soon, because of the hurdle. My brain isn’t like a tree, which I can ax as much as possible to fall it. It needs sufficient rest.

I’ve recently been trying a new method which seems to work - waiting. When I’m stuck, I take a good rest and come back the next day. And if that fails, I take off more time, to work on something else that’s useful. One fine day, the solution just magically shows itself when you aren’t even thinking too much. I understand that this isn’t possible when working against deadlines. But there’s always sometime that you can spare to give your brain a rest. Maybe it just needs some Starbucks or even writing some always-to-be-obscure Node.js framework.

Give it time. There’s no need for solution marathons.