About progamming with Multi-Touch, Touch- and Mouse-Events in the webbrowser

Since there are more and more touch-capable devices out there, as a web-developer it becomes more and more important to know how to deal with touch events next to mouse events and how you you can combine both worlds (mouse and touch interaction).

Here's a quick introduction to (multi-)touch browser events and an advanced article that deals with touch and mouse events and how they can be combined.

How to copy your „Google Chrome“ or „Chromium“ profile without creating an online account

Google Chrome saves your profile data in ~/.config/google-chrome.
To transfer the profile to for example a system you have setup freshly do following steps:

  • make a copy of ~/.config/google-chrome
  • install google-chrome
  • restore your backuped profile to ~/.config/google-chrome
  • launch google-chrome

(Replace google-chrome by chromium-browser if you use chromium-browser)

Ensure reloading of favicons

Sometimes it seems a favicon does not work because your browser displays an old version or (in case of local development) a favicon of another project you worked on recently.

Though, you can force your browser to really reload the favicon using some kind of additional version parameter string like this:

= favicon_link_tag("/favicon.ico?v=2")
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...

Ruby 1.9 or Ruby 2.0 do not allow using shortcut blocks for private methods

Consider this class:

class Foo

  def test
    puts "Hello"

While you can say create a block to call that method (using ampersand and colon) on Ruby 1.8, …

1.8.7 >
=> #<Foo:0x1e253c8> 

… you cannot do that on Ruby 1.9 or 2.0:

1.9.3 >
NoMethodError: private method `test' called for #<Foo:0x00000001e8c258>
2.0.0 >
NoMethodError: private method `test' called for #<Foo:0x000000027bc738...

How to: Ruby heredoc without interpolation

When you use heredoc, string interpolation is enabled by default:

x = "Universe"
  Hello #{x}
# => "Hello Universe"

This may be impractical sometimes. To avoid interpolation in heredoc strings, simply enclose your heredoc marker with single quotes:

x = "Universe"
  Hello #{x}
# => "Hello #{x}"

That will make the string behave like a single-quoted string, so sequences like \n wil…

Loading dumps via SSH, unpacking and sourcing them, all with a progress bar

Here is a hacky way to load dumps directly from the source server, without fully copying them over and extracting them first.

It may break horribly for you. This is the dark side of the force.

  1. Install pipe viewer, if you don't have it already: sudo apt-get install pv
  2. Know the location of the dump file on the remote server. We'll use /mnt/dumps/my_project.dump.bz2 in the example below.
  3. Find out the size of the (bzipped) file in by…

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.

Different behavior for BigDecimal#floor in Ruby 1.8 and Ruby 1.9

Ruby 1.8 (supplied by Rails' ActiveSupport)

=> BigDecimal

Ruby 1.9 (supplied by Ruby 1.9 itself)

=> Fixnum

In fact, Float#floor has changed from Ruby1.8 to Ruby 1.9 which is used by BigDecimal#floor internally.

Attached initializer backports Ruby 1.9 behavior to Ruby 1.8.

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 %>
3345 cards