fixing a bad commit with git-svn

Posted by jacqui maher on March 25, 2008 at 05:28 PM

I do this fairly often, mostly because I haven’t migrated all of our svn pre-commit hooks to git. I really ought to do that..

$ git tag bad 012345 # or any other valid git reference
$ git checkout bad
$ # make changes here and update the index
$ git add
$ git commit –amend
$ git rebase –onto HEAD bad master # where ‘master’ is the branch in question
$ git tag -d bad

thanks to sebastian delmont for this.

Comments: 3 (view/add your own) Tags: git, svn

speedy browsing

Posted by jacqui maher on March 20, 2008 at 07:45 PM

I’ve been using the Firefox 3 beta for about a week now and I’m really happy with it so far. It’s a lot faster and less of a memory hog in OSX than its predecessor. The one thing I was wishing for was the beautiful, extremely useful, firebug extension… I kept opening Firefox 2 whenever I needed to do UI work.

Then I realized I hadn’t even checked if Firebug was compatible with Firefox 3, aside from the initial plugin compatibility check that Firefox does on its first run.

Lo and behold: the latest firebug beta works with Firefox 3 beta release 4! YES!

so what are you waiting for? install it now:
firebug beta xpi

guns don't kill people...

Posted by jacqui maher on March 20, 2008 at 09:43 AM

I saw this picture in the NYTimes today. It really appeals to my admittedly dark sense of humor:


photo credit: Stephen Crowley/The New York Times

Comments: 2 (view/add your own) Tags: heh

gadget gogo

Posted by jacqui maher on March 20, 2008 at 09:37 AM

isn’t this awesome?!



This camera is cute, small, nice-looking (hey that’s different than cute!), and really affordable. I think I’m going to get one.

Comments: 1 (view/add your own) Tags: gadget

[ERROR] Can't locate object method "install" via package

Posted by jacqui maher on March 11, 2008 at 01:14 PM

In case anyone else runs into this…

I was installing NCPL today when I ran into a missing CPAN module. I used to do a lot of Perl programming back in the day but I have to admit it’s been awhile since I’ve installed a CPAN module.

   1  [root@server NCPL-1.000050]# perl Makefile.PL 
2 ExtUtils::MakeMaker v6.31, required for 'perl Makefile.PL' via CPAN


Hrm, ok. I remember doing this with CPAN’s interactive shell…

   1  [root@server NCPL-1.000050]# perl -MCPAN -e 'install ExtUtils::MakeMaker'
2 Can't locate object method "install" via package "ExtUtils::MakeMaker" at -e line 1.


Uhmm.. ok. What the?

I googled around trying to figure out why this was causing an error on the method “install” when I suddenly realized: this is a brand new server. No one has ever run perl -MCPAN on it, I would bet.

   1  [root@server NCPL-1.000050]# perl -MCPAN -e shell
2
3 /usr/lib/perl5/5.8.8/CPAN/Config.pm initialized.
4
5
6 CPAN is the world-wide archive of perl resources. It consists of about
7 100 sites that all replicate the same contents all around the globe.
8 Many countries have at least one CPAN site already. The resources
9 found on CPAN are easily accessible with the CPAN.pm module. If you
10 want to use CPAN.pm, you have to configure it properly.
11
12 If you do not want to enter a dialog now, you can answer 'no' to this
13 question and I'll try to autoconfigure. (Note: you can revisit this
14 dialog anytime later by typing 'o conf init' at the cpan prompt.)
15
16 Are you ready for manual configuration? [yes] yes


AHA!! It just needed to be configured. That was easy :)

better git status

Posted by jacqui maher on March 07, 2008 at 05:01 PM

My typical morning usually goes like this:

- put the laptop on desk & turn it on
- get coffee :)
- open adium/textmate/firefox/terminal/etc.
- type: git status in my project’s RAILS_ROOT
- try to recall what I did in those local modifications, and then either copied and pasted (ugh I hate having to use the mouse!) the paths for each file, or tab-completed each file path, to open it in Textmate… or opened the project, cmd-T, searching for each.

The thought had occured to me several times that there must be a better way.

This is what I came up with, and so far, it works for me.

   1  tinsel:bin jm$ ./gitstatus -h
2 Usage: gitstatus [options] [paths ...]
3
4 Specific Options:
5 -d, --diff Show git diff output for each locally modified file.
6 -t, --textmate Open each locally modified file in Textmate.
7 -h, --help Show this message


Example:

   1  tinsel:workspace jm$ ~/bin/gitstatus -d
2 [MODIFIED]: app/controllers/listings_controller.rb, app/models/listing_criteria.rb, config/environment.rb, plugins/criteria/lib/criteria/criteria.rb
3 [DELETED]: spec/rcov.opts
4 [UNTRACKED]: script/import/nnj/njtransit.rb, spec/fixtures/nyc_data_pad_addresses.yml, spec/fixtures/nyc_data_pad_buildings.yml, spec/fixtures/nyc_data_street_names.yml
5
6 ************app/controllers/listings_controller.rb************
7 diff --git a/app/controllers/listings_controller.rb b/app/controllers/listings_controller.rb
8 index 74a0e6c..4d11c1e 100644
9 --- a/app/controllers/listings_controller.rb
10 +++ b/app/controllers/listings_controller.rb
11 @@ -141,10 +141,10 @@ class ListingsController < ApplicationController
12
13 def search
14 -
15 +debugger
16 - if(@criteria[:area] && @criteria[:area].index(",") == nil)
17 + if(@criteria[:area] && @criteria[:area].index(",") == nil)
18
19
20 open in textmate? [Yn] _


If you want it, go ahead and grab it: gitstatus.rb

snippet: grab webpage and save it for future traversing

Posted by jacqui maher on March 04, 2008 at 03:47 PM

I use this method to grab a webpage and then access it later. It’s useful if you’re trying to scrape a page, for example, and don’t want to keep hitting it over the network. Note that I use this as part of a class which initializes the variable @local_dir at instance creation.

   1  def get_local_or_remote(id, webpage_uri_format)
2 html = ""
3 if File.exists? "#{@local_dir}/#{id}.html"
4 html = File.read("#{@local_dir}/#{id.html")
5 else
6 webpage_uri = if webpage_uri_format.match(/:id/)
7 webpage_uri_format.gsub(":id", id)
8 else
9 webpage_uri_format
10 end
11
12 html = insist(:delay => 60) do
13 Net::HTTP.get_response(URI.parse(webpage_uri)).body
14 end
15
16 stfile = File.new("#{@local_dir}/#{id}.html", "wb")
17 stfile.puts(html)
18 stfile.close
19 end
20
21 return html
22 end

snippet: saving data to a file to use as an input later

Posted by jacqui maher on March 04, 2008 at 01:41 PM

I find myself doing this often.

   1  >> data = Model.find_all_by_something("Something")
2 # => [... results...]
3
4 >> File.open("#{RAILS_ROOT}/db/data/somethings.yml", "w") do |f|
5 > f.puts data.to_yaml
6 > end