How do dump a Javascript object’s methods

 
for(var i in objectname) {console.log(i);}

Decoding the Rails session cookie

 
Marshal.load(Base64.decode64(CGI.unescape(cookie.split("\n").join).split('--').first))

As found here.

Update: you can dump your session and verify your session signature using:

 
secret = "your session secret" # from config/initializers/session_store.rb
verifier = ActiveSupport::MessageVerifier.new(secret)
signed_message = CGI.unescape(cookie.split("\n").join
verifier.verify(signed_message)

How to optimize a Solr index from Sunspot

It doesn’t look like SunSpot has a builtin optimize command.
Here’s one way you can do it:

 
Sunspot.session.session.send(:connection).update RSolr::Message::Generator.new.build { |b| b.optimize }

Anyone know of a simpler one?

A whole new level of Fluid Layout

Courtesy of Jacob Maine:

This is a whole different level of fluid layouts: http://hicksdesign.co.uk/journal/finally-a-fluid-hicksdesign. Worth playing with.

And the tools it’s based on: http://www.alistapart.com/articles/responsive-web-design

Resque

Github’s excellent analysis of the extant background jobs runners and introduction to Resque

Selenium-RC and Snow Leopard

Selenium-RC was having issues on Snow Leopard:

 
dyld: Library not loaded: /usr/lib/libsqlite3.dylib
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Reason: Incompatible library version: Security requires version 9.0.0 or later, but libsqlite3.dylib provides version 1.0.0

Web searches produced a lot of information including some workarounds that didn’t. Finally I read that Selenium-RC 1.x has some hardcoded paths in it that mean it won’t work with Snow Leopard, and you need to get the Selenium-RC 2.x jar (alpha at this time). The easiest way to do this is to install the selenium-rc gem that Pivotal packaged.

[Update]

More recently, have been having issues running Cucumber/Webrat/Selenium on new MacOS systems. It turns out that Webrat contains an out-of-date version of the selenium server jar file. If you are using Webrat, you need to copy the good selenium-server.jar from the selenium-rc package over the version contained in the Webrat gem. Something like:

 
sudo cp /Library/Ruby/Gems/1.8/gems/selenium-rc-2.2.1/vendor/selenium-server.jar /Library/Ruby/Gems/1.8/gems/webrat-0.7.0/vendor/selenium-server.jar

RubyMine not recognizing cucumber features

If RubyMine isn’t recognizing cucumber features, ensure the following:

  1. Cucumber gem is attached to project: RM | Settings | Ruby SDK and Gems | Attach gems.
  2. If you edited *.feature files in early version of RubyMine it may be mapped on Text file. So you should check that *.feature extension is mapped on “Cucumber scenario files” in RM | Settings | File Types | Recognized File Types.

per Roman at JetBrains

Superstar Developers

Zed Shaw is at it again. This is an excellent post, that contains much truth: 3 Simple Rules That Will Make You a ‘Superstar’ Developer.

Which also provoked a great comment.

Setting up Synergy keyboard/mouse sharing

Download synergy from http://sourceforge.net/projects/synergy2/files/ and install on the machines you want to participate in sharing. For this example let’s say I two systems with hostnames notebook and desktop, and I want to share the keyboard and mouse of desktop.

Create a configuration file, something like this:

 
section: screens
  mydesktop:
  mynotebook:
end
 
section: links
  mynotebook:
    left = mydesktop
 
  mydesktop:
    right = mynotebook
end

On desktop run:

 
synergys -f --config synergy.conf

On notebook run:

 
synergyc -f desktop

Easy rspec matchers

http://rspec.rubyforge.org/rspec/1.2.9/classes/Spec/Matchers.html