Satya's blog - 2011/03/

Mar 27 2011 17:56 How to reset your Linux mouse

Based on if your mouse pointer gets stuck (because your KVM switch screwed up, as mine did) and you don't want to reset because you're in the middle of a non-saveable game, you can do this in a terminal:

sudo rmmod psmouse
sudo modprobe psmouse

While you don't have a mouse, here are some handy shortcuts for use with Ubuntu and Gnome:

Switch windows. Hit once to alternate between two windows. Hold down alt and keep pressing tab to reach other windows.
Run command. You can run gnome-terminal from here to get a command line. alt-1 etc switch terminal tabs. ctrl-shift-t opens new tab.
(Firefox) search bar
(Firefox) address bar. In Firefox, Ctrl-w closes current tab, ctrl-t opens new tab, ctrl-tab cycles through tabs.

Last updated: Mar 27 2011 18:04

Tag: mouse howto

Mar 14 2011 16:07 Gemfile.lock in Rails 3 so that my Rails 2 apps can run in a Rails 2 + Rails 3 environment (I run Ubuntu, apt-get ruby, and gem install rails).

The instructions amount to: 1. put this code in environment.rb above the Rails.boot! line:
class Rails::Boot
  def run
    Rails::Initializer.class_eval do
      def load_gems
        @bundler_loaded ||= Bundler.require :default, Rails.env
2. put this in config/preinitializer.rb:
  require "rubygems"
  require "bundler"
rescue LoadError
  raise "Could not load the bundler gem. Install it with `gem install bundler`."

if <="0.9.24")
  raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
   "Run `gem install bundler` to upgrade."

  # Set up load paths for all bundled gems
  ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
rescue Bundler::GemNotFound
  raise RuntimeError, "Bundler couldn't find some gems." +
    "Did you run `bundle install`?"
3. This'll do for your Gemfile:
source :gemcutter
gem "rails", "~> 2.3.5"
gem "sqlite3-ruby", :require => "sqlite3"

(reproducing the instructions here mostly for myself.)

That Gemfile goes in your application's rails root, i.e. the parent of app/ and config/. Okay, fine. So I set up an application that way, and it worked. I then commented out the 2.3.5 and it continued working. So I set up another application the same way and it failed. After 2 hours of headbanging, I realised that the Gemfile.lock was being used instead. Symptom: rails fails to start with:

    no such file to load -- initializer

Now if you start it at least once with the 2.3.5 NOT commented out, it'll keep working even after you do comment it out. Might be a weird permissions interaction, though.

The rant here is, .lock files are a *nix convention for, well, locking. As in concurrency control. Transient files. This Gemfile.lock isn't that kind of file. And it needs to be writable by the web server, unlike all the other files in your rails root. Ugh.

Tag: rant rails