agaskar.com

Dec 15 2009
First, you need to include the library and create a new instance using the new2 method (or new with a lot of parameters or new3 with a hash of every parameter needed; it’s sort of up to you).

according to this Ruby tutorial slideshow transcription, these are the basic differences between new, new2, and new3 constructors for xmlrpc. Can I take a moment to salute the careful consideration that was given to these names? [1]

[1] Yes, I am using my middle finger here.

Comments (View)
Dec 10 2009

if ENV[‘RAILS_ENV’] == ‘production’
ENV[‘GEM_PATH’] = ‘/home/USERNAME/.gems’
require ‘/home/USERNAME/.gems/gems/rack-1.0.0/lib/rack.rb’
end

is apparently the crap you have to add to get the correct version of rack on dreamhost. Really? That seems like a pain in the ass.

Comments (View)
Oct 31 2009

rspec, errors, and idiocy

Just spent ten minutes writing a test that should’ve taken thirty seconds. The final test looks like this:

it "should throw an Already Running error if there is already a server running" do
    some_thing.should_receive(:some_method).and_raise(RuntimeError.new('no error'))
    lambda {
      some_thing.that_triggers_the_error()
      }.should raise_error(RuntimeError, "some error")
end
The first mistake was mine. I wrote:
some_thing.should_receive(:some_method).and_throw(RuntimeError.new('some error'))
Too much javascript, I guess. But the crazy thing is, yes, it throws. You end up getting a NameError: uncaught throw for ‘some error”. Super confusing, right? Easy mistake to make, though. The second issue is more of an rspec message shortcoming. I originally had:
 .should raise_error(RuntimeError.new('some error'))
which resulted in the matcher error:
expected some error but nothing was raised 
But something *was* raised — it just wasn’t being matched correctly because I used the wrong matcher arguments. This is, yes, technically also my fault, but the unhelpful matcher error makes it difficult to catch. Anyways, hopefully this gotcha description finds its way into the hands of people who need it, since google wasn’t super helpful when I dropped in some key words.

Comments (View)
Jul 01 2009
Comments (View)
Jun 17 2009
Comments (View)
Jun 14 2009

OSX Style Keymap: Swapping WIN and ALT keys on Ubuntu to act as ALT and META keys (respectively)

I’m 100% lost without the Rubymine keymap for OS X. (Not ‘Default for OS X’, but ‘OS X’). This is available on the Ubuntu version, however, my keymap out of the box was not supported. By default, my left ALT key sends ‘left ALT’, and my Win key sends ‘Win’ (which, yes, is pretty sensible). I wanted my left ALT key to send ‘Meta’ (essentially ‘Command’), and my left Win key to send ALT. After tweaking with xmodmap for about an hour, I finally came up with an .Xmodmap file that does what I want (just drop this in your user dir — note the case-sensitivity — and Ubuntu should prompt you to load it automatically next time you login):

clear mod1
clear mod4
keycode 133 = Alt_L
keycode 64 = Meta_L
add mod1 = Alt_L
add mod4 = Meta_L


I probably need to remap all the keys to be more mac-y (IE, copy on META+C, instead of CTRL + C), but at least the Rubymine keymap seems to be acting mostly as I’d expect.

Comments (View)
+
Have you checked in the current profile of gnome-terminal the option “Run command as a login shell” ? If this is not enabled, I think ~/.bash_profile is not loaded.
— how to get .bash_profile sourced when launching Terminal in Ubuntu: Ubuntu question #1770: “configure the .bash_profile”
Comments (View)
Jun 13 2009

awesome git plugin gotcha

1. (apparently) git considers any directory with a .git file in it as a submodule.
2. the restful_authentication recommends cloning instead of using script/plugin (which removes the .git file) because of naming issues.
3. capistrano does not appear to pull git submodules by defaul

1 + 2 + 3 = tests pass on local, but production can’t run (because the plugin code doesn’t deploy).

fun.

update: of course, the obvs fix is to remove the .git file, then redeploy. Git doesn’t like to rm submodules, so I had to rm -rf the dir, then git rm it, then grab a copy without a .git file and add it.

Comments (View)
+

rspec w/ frozen rails

Getting this error on all your controller tests?

ArgumentError in ‘Controller::TestCase should destroy user’
wrong number of arguments (0 for 1)

Possibly an impedance mismatch between some gem and the frozen version of rails. Either way, upgrading to 2.3.2 in my vendor/rails fixed it for me. But man, was that ever hard to figure out.

Comments (View)
Jun 12 2009

could not find any SCM named git

Capistrano deploy problems.

Happened to me.

Here’s the story.

1) you probably don’t have the correct keys on your target machine to git pull from your git repo. Make sure you can do a git pull where you’re deploying to.

2) scm_command and scm settings seem to get called as methods. If they’re set to anything but ‘git’ (like, a full path), you’re probably screwed.

3) Make sure you have the latest version of Capistrano installed.

update: :copy is SUPER slow for me (tried to SFTP to dreamhost, canceled after 8M took 30 minutes to upload). :remote_cache copies from gitosis quickly and easily (under 10 seconds). Not sure why the diff.

Comments (View)
Page 2 of 8 Newer Entries →