Tuesday, December 9, 2008

Coda Plug-in: Remove Trailing Whitespace

Edit: Erik Hinterbichler has written a much better native plugin called White Out. I highly recommend using that one instead of this one.

I've been using Coda to do all of my programming for quite some time now. One thing I wish it had, though, is the ability to remove trailing white space from lines when the file is saved.

With Coda 1.6 they added the ability to create plug-ins, and with the release of 1.6.1 a few days ago they have added the ability to manipulate the whole document with plug-ins. After hearing this I decided to write my own to take care of that pesky trailing white space issue. Coda doesn't have the ability to have plug-ins run upon file save, but it's the best I could do with what they provide and what I know how to do.

You can download the plug-in here:


Remove Trailing Whitespace v1.0

Here is the code I used to write it. The $$IP$$ stuff is so that the insertion point remains where it was before the code is run. If I leave it out, the insertion point goes to the end of the file. You can also visit its github repository.

#!/usr/bin/ruby

ip_line = ENV['CODA_LINE_NUMBER'].to_i
ip_index = ENV['CODA_LINE_INDEX'].to_i

$stdin.each_line do |line|
  line.rstrip!

  if $stdin.lineno == ip_line
    ip_index = line.length if (line.length) < ip_index
    line = line.insert(ip_index, "$$IP$$")
  end

  print line
  print ENV['CODA_LINE_ENDING']
end

Thursday, December 4, 2008

Yet Another Reason Jeff Atwood Has No Common Sense

I'll admit it -- I do read Jeff Atwood and Joel Spolsky. When they announced stack overflow, I was intrigued and signed up for the beta. They only accept OpenID, so I decided to create a new blogger site: kevinglowacz.blogspot.com. I played around a little and it seemed like a nice concept.

About a month later I decided to start utilizing my blog. I bought this domain name (glowacz.info) and setup my blogspot account to redirect to kevin.glowacz.info. Well this means when I try to log in to stack overflow with kevinglowacz.blogspot.com it redirects and logs me in as kevin.glowacz.info. That's fine, I'd like my OpenID to be my domain anyway. I just didn't want to lose what I had done with my other account.

I looked around and saw that others had also had circumstances where their OpenID changed and they were able to get their accounts merged by emailing Jeff. I shot an email over to Jeff Atwood explaining my situation and asked him to change the OpenID on my old account to my new OpenID. I also purposefully did nothing (except post a question asking to merge my accounts) with my new account so he wouldn't have to merge anything -- he'd just have to change the OpenID on my old account.

However, instead of just changing the OpenID on my old account, Jeff took all of my questions and answers from my old account and attached them to my new account. Because of this I lost all of my profile info, my "Member for x days" data, and my esteemed "Beta Badge".

Now I don't know how they have their database set up over at stack overflow, but I have to imagine that changing the OpenID associated with my old account would have to be easier than moving all my questions and answers over to my new account. I even specifically asked for the associated OpenID to be changed instead of asking for the accounts to be merged. Clearly, Jeff Atwood has no common sense.