Capistrano: Bundler stalls and asks for "Username"

Given you use Capistrano together with bundler to automatically install your gems when deploying.

I recently had the problem that Capistrano stalled like this:

[err ::] Username:

It turned out that I this originated from GitHub. We had a gem in our Gemfile that explicitly pointed to a GitHub URL like that:

gem 'foogem', :git => ''

The URL was returning a 404 which caused the problems. You have to get another gem or point to a fork on GitHub.

How to find out your Ubuntu's release codename or version

So you want to know if you are on natty, precise, quantal, or something else? Check /etc/lsb-release.

$ cat /etc/lsb-release 

Or, use the lsb_release command:

$ lsb_release -cd
Description:	Ubuntu 14.04.1 LTS
Codename:	trusty

MongoMapper for Rails 2 on Ruby 1.9

MongoMapper is a MongoDB adapter for Ruby. We've forked it so it works for Rails 2.3.x applications running on Ruby 1.9. [1]

makandra/mongomapper is based on the "official" rails2 branch [2] which contains commits that were added after 0.8.6 was released. Tests are fully passing on our fork for Ruby 1.8.7, REE, and Ruby 1.9.3.

To use it, add this to your Gemfile:

gem 'mongo_mapper', :git => 'git://', :branch => 'rails2'   ...

Fix error "invalid byte sequence in US-ASCII" in .js.erb files

This error can happen in Ruby 1.9.

To fix it, add the following line to the top of your .js.erb file:

<%# @encoding: UTF-8 %>

A regular expression that will never match

So you have a method returning a regular expression but one case that should not yield a matching Regexp object but still keep the API stable? Just return one that never matches:


Git: How to check out branches that exist on multiple remotes

So you're using multiple remotes that offer the same branch?

$ git branch -a | grep my-branch

And when trying to check out that remote branch, it fails for you with an error like this?

$ git checkout my-branch
error: pathspec 'my-branch' did not match any file(s) known to git.

Git usually guesses the remote branch to check out, but when using more than one remote, it seems like it no longer can do that.
Even if the branch is the same on both remotes, you nee…

External content

The Startup Toolkit

Good collection of crash-course articles about founding a start up, getting funded, validating ideas, etc.

SFLPhone won't start

You might get the following error:

Unable to initialize.
Make sure the daemon is running.
Error: Process /usr/lib/sflphone/sflphoned exited with status 1

This mean the last process didn't shut down properly and let a PID file lie around. You can delete it with

rm ~/.cache/sflphone/

(If you've shut sflphone down some seconds ago, you just have to wait 10 seconds and don't have to remove the pid file manually)

"Module.const_defined?" behaves differently in Ruby 1.9 and Ruby 1.8

Ruby 1.9 changed the default behavior of Module.const_defined? from what it was in Ruby 1.8 – this can be especially painful when external code (read: gems) uses const_defined? to look something up and gets different results on different Rubies.

Consider this:

module Foo
  FOO = 42

class Bar
  include Foo

On Ruby 1.8, Bar won't have FOO defined as a constant since that's (even though it's accessible):

1.8.7 > Foo.const_defined? :F...

How to silence UTF-8 warnings on Rails 2.3 with Ruby 1.9

Rails 2.3.16+ on Ruby 1.9 causes warnings like this:

.../gems/activesupport-2.3.17/lib/active_support/core_ext/string/output_safety.rb:22: warning: regexp match /.../n against to UTF-8 string

Many thanks to grosser for supplying a monkey-patch for Rails 2.3 (Commit f93e3f0ec3 fixed it for Rails 3). Just put it into config/initializers/ to make those warnings go away.

Since we're using RSpec on mos…

Capturing signatures on a touch device

If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent Signature Pad plugin for jQuery.

To implement, just follow the steps on the Github page.

The form

If you have a model Signature with name: string, signature: text, you can use it with regular rails form like this:

- form_for @signature, :html => { :class => 'signature_form' } do |form|
      = form...

Fix warning "already initialized constant Mocha" with Rails 3.2

You either have an old version of Mocha and an edge version of Rails 3.2, or you have a new version of Mocha and an old version of Rails. The best solution is to update Mocha to the latest version and switch to Rails edge.

If you are using shoulda-matchers or another gem that locks Mocha to an old version, you are out of luck.
More info with many other workarounds that you do not want to use can be found here. A hack to work around this case is to add the following file to lib/mocha/setup.rb:…

Test xpath expressions in your browser

Safari & Chrome

Use $x() in your console:

$x('//span') # selects all span elements


There's an add-on.

External content

Firefox 22 to Stop Eating Third-Party Cookies

Mozilla has announced that, starting with Firefox 22, the popular open source web browser will begin blocking third-party cookies by default. That means only websites you actually visit will be allowed to set cookies; advertisers on those sites will no longer be able to easily track you by setting a cookie.

Extracting the conditions of a named scope in Rails 2.3

See attached link for a way to extract the conditions of a named scope in Rails 2.3.

External content

Firefox introduces PDF viewer

Prepare to explain customers what changed if your application renders PDF documents to users.

How to fix: Microphone recording levels are too quiet (or get lowered automatically)

If others on a call (Skype, SIP, …) can not hear you loud enough, your volume levels are probably too low. Also, Skype may be changing your mixer levels.

Set a proper recording volume

  1. Open your mixer software (run pavucontrol).
  2. Switch to input devices.
  3. If you have more than one recording device, find the correct one.
  4. Make a test call to a colleague that can tell you if it's too loud or too quiet.
  5. Drag the volume slider for your input device to an adequate level – for me, 75% (-7.46dB) work fine. 100% is usually way to…
External content

Using CSS counters - CSS | MDN

Counters are an awesome CSS feature you didn't know about. It is supported in all browsers and IE8+.

CSS counters are an implementation of Automatic counters and numbering in CSS 2.1. The value of a counter is manipulated through the use of counter-reset and counter-increment and is displayed on a page using the counter() or counters() function of the content property.

3409 cards