I use git a lot. And I use just about any text editor in my system to edit files. And they tend to come with baggages of their own. Albeit useful, the swap files tend to linger on and eventually end up in my git repository. Here’s how to avoid that scenario.
Git (okay I remember this from doing the same thing in subversion, so nothing new) has something called pre-commit. Pre-commit is just a script/action you can perform on the repository before committing. So, here’s what you need to do
I’ll use vim here, but use whatever you like
$ vim .git/hooks/pre-commit
and put this:
#!/bin/sh
find . -name ‘*~’ -exec rm \;
find . -name ‘*.swp’ -exec rm \;
This removes two types of files, those generated by vim and gedit. There should be a much more elegant way to include more file types, I’ll update them as I refine my pre-commit hook more.
Just noticed this “block selection” feature in eclipse. What this lets you do is select a block of text instead of just lines. Suppose you wanted to copy
1 class Hello:
2 def __init__(self):
3 print “hello”
If you wanted to copy this, I’d put in vim and run :%s/^\(\d\+\)\s //g [Double check this]
to remove the line numbers or depending on how much I’d like to tinker, perl.. Now I can just do it in eclipse. Something I’ve wanted to do since my pre-regexp days..
Notepad++ has had this feature since forever, but its nice to see this in eclipse finally.
http://www.vasanth.in/2009/03/31/eclipse-tip-block-selection-mode/
Granted, it doesn’t really really add much for me personally, I’ve heard a bunch of people ditching eclipse for Notepad++, so here you go!
Cheers!
This is currently my (okay, one of my) favorite song(s).
I think the chorus is great
I wanted you to know I love the way you laugh
I wanna hold you high and steal your pain away
I keep your photograph and I know it serves me well
I wanna hold you high and steal your pain
‘Cause I’m broken when I’m lonesome
And I don’t feel right when you’re gone away
You’ve gone away, you don’t feel me, here anymore
The worst is over now and we can breathe again
I wanna hold you high, you steal my pain away
There’s so much left to learn, and no one left to fight
I wanna hold you high and steal your pain
[x2]
‘Cause I’m broken when I’m open
And I don’t feel like I am strong enough
‘Cause I’m broken when I’m lonesome
And I don’t feel right when you’re gone away
‘Cause I’m broken when I’m lonesome
And I don’t feel right when you’re gone away
I was trying to add (re-add) the feature to let users generate their very own POSIT versions. It used to be there when I was working on it initially and I’d completed it reasonably last summer. The idea was chucked away as we moved on. But, now we wanted it back.
The first thing to do in a case like this, is to figure how to compile an apk. One of the criterias I’ve put for myself is, this program absolutely must work (in 1.0 I mean ) without internet connection also as POSIT is supposed to be used for disaster recovery.
Ok. Let’s get down to business, the first time I’d implemented this, I had a django webapp (we have php now, 3rd rewrite) that would exec ‘ant build’ to generate a custom POSIT app.
Thanks to subversion, I was able to grab that build.xml from the old code. As naive as we programmers can sometimes be, I really did think this would work.. somewhat, maybe 20 mins tops.. lol
But, with new versions, things have changed a lot, we don’t have R.java in src folder and a lot of the tools aren’t in same place or accept the same arguments, notably aapt tool.
After fumbling for an hour or so trying to created a build.xml that worked, I felt.. hey, this is Google, I bet they thought of this and have a tool. ( I did try to search for activitycreator.py that was used to generate a generic build.xml file)
And lo and behold…
I read the Manual…. http://developer.android.com/sdk/1.5_r1/upgrading.html
It said that the new tool ‘android’ can be used to create the build.xml automatically…
This stop-motion ad by the New Zealand Book Council makes me glad I don’t own a Kindle or a Nook, and it makes me want to go grab a book immediately. Preferably a gritty New Zealand western.
So, I’ve been using cygwin for a while now and I am not impressed at all by the default shell for the following reasons:
1. It’s clumsy. I can’t resize properly.
2. Doesn’t take NUL character apparently
3. Backspace is acting weird so far.
4. cmd.exe looks ugly!
However, putty is pretty amazing in terms of usability. I finally found the solution with puttycyg which adds an option to run a cygwin terminal session on putty.
This might turn out to be a bit of a series. Although this is fairly useful script to have, for most purposes, you would just install one of the packages. This is useful if you’re installing a lot of packages that have some attribute common.
So, I’ve been using windows on my new Netbook. This is the first time I’ve really decided to use cygwin for day to day stuff and actually trying to make it productive is quite a work. One of the things I noticed was that the regular editors like vim and emacs had a lot of trouble adapting to cygwin. For example, backspace doesn’t work for vim and Ctrl-X, Ctrl-C combination didn’t work for emacs for me (I even double checked with google to check if my fingers lost their mojo).
I name this file np (in true Unix fashion of naming things as shortly as possible ) and place in my ~/bin for maximum adaptability.
#!/bin/bash
# Edit your cygwin files in notepad++, the best windows editor.
# Vim and emacs don't seem to work too well in cygwin.
ROOT_DIR_WINDOWS=D:\\\\cygwin
expandToWindows() {
y=`echo $1| sed -e 's/\//\\\\/g'`
echo $ROOT_DIR_WINDOWS\\$y
}
expArg=`expandToWindows $1`
echo $expArg
/cygdrive/c/Program\ Files/Notepad++/notepad++.exe $expArg
Just copy this script into your ~/bin or /usr/bin and make it executable to run as
np <file you want to edit>
So, this runs just like any other unix script. I don’t know if you can pass multiple arguments for notepad, if so feel free to extend this piece of code and give me a howler so that I can improve too.
Of course, you can do the same for any other windows application.