Request limit of graph.facebook.com

The facebook API allows up to 600 requests per 600 seconds.
If you poll more often, you'll get no or malformed answers.

PhoneGap Build

Write your app using HTML, CSS or JavaScript, upload it to the PhoneGap Build service and get back app-store ready apps for Apple iOS, Google Android, Windows Phone 7, Palm, Symbian, BlackBerry and more.

By compiling in the cloud with PhoneGap Build, you get all the benefits of cross-platform development but can still build apps just the way you like.

Drag'n'drop in trees: I went to town

For my Gem Session project Holly I ran the Ironman of drag'n'drop implementations:

  • Dragging in nested lists
  • User-definable order of items
  • Complicated item elements with super-custom CSS and other Javascript functionality
  • Items that can be both leaves and containers of other items
  • has_ancestry on the server side

Things I learned:

  • Be ready to write a lot of CSS. You need to indicate what is being dragged, where it will be dropped, if it is dropped above, below o...

Nice way to set data attributes when creating elements with Rails helpers

You can say this in helpers like link_to and content_tag:

= link_to 'Label', root_url, :data => { :foo => 'bar', :bam => 'baz' }

This will produce:

<a href="/" data-foo="bar" data-bam="baz">Label</a>

Only works in Rails 3. In Rails 2 you do

= link_to 'Label', root_url, 'data-foo' => 'bar', 'data-bam' => 'baz' }

How to enable MySQL query logging

This will make MySQL log all received queries so you can see for yourself what happens on the database level.

Don't switch this on for production machines!

  1. Edit your my.cnf:
    sudo vim /etc/mysql/my.cnf
  2. In the [mysqld] section, add:
    log=/var/log/mysql.log
  3. Restart your MySQL daemon. On Ubuntu:
    sudo service mysql restart

Note that your MySQL performance will suffer. But when you need to enable query logging for a debug fest, you probably don't care about that.

jQuery.cssHooks – jQuery API

The $.cssHooks object provides a way to define functions for getting and setting particular CSS values. It can also be used to create new cssHooks for normalizing CSS3 features such as box shadows and gradients.

For example, some versions of Webkit-based browsers require -webkit-border-radius to set the border-radius on an element, while earlier Firefox versions require -moz-border-radius. A css hook can normalize these vendor-prefixed properties to let .css() accept a single, standard property name (border-radius, or with DOM property synt...

Updated: Capybara: Check that a page element is hidden via CSS

  • The step we used in the past (Then "foo" should not be visibile) doesn't reliably work in Selenium features.
  • I overhauled the entire step so it uses Javascript to detect visibility in Selenium.
  • The step has support for jQuery and Prototype projects, so it should be a drop-in replacement for all your projects.
  • For Rack::Test the step no longer uses XPath so you should be able to understand it when you are not a cyborg :)
  • There were some other cards detailing alternative steps to detect visibility. I deleted all these other cards s...

Update Skype 4.x to at least 4.0.0.8

There was a bug in Skype that could cause messages to be sent to incorrect recipients (anyone, not only people from your contact list).

If you were using Skype 4 on Linux (or Skype on any other platform), upgrade immediately.

I don't know if Skype 2 on Linux is affected.

Updated: Check whether an element is visible or hidden with Javascript

  • Added information about what jQuery considers "visible"
  • Added a solution for Prototype
  • Added a patch for Prototype that replaces the useless Element#visible() method with an implementation that behaves like jQuery.

RubyMine: Using pinned tabs will increase your productivity

I highly recommend that you make use of RubyMine's feature to pin tabs.

When you pin all "important" files, you can follow method definitions, wildly open files from search results and have a ton of open tabs -- without the problem of finding the stuff you were working on before.

Guide

  1. Pin the tabs of files that are currently in the focus of your work (important models, specs, etc):
    • Right-click a tab and select "Pin tab"
    • Or use a shortcut (see below)
  2. Work as usual.
  3. Once you opened other tabs because you searched ...

Click on a piece of text in Cucumber / Capyabra

The step definition below lets you write:

When I click on "Foo"

This is useful in Selenium features where the element you click on is not necessarily a link or button, but could be any HTML element with a Javascript event binding.

The easiest way to get this step is to use Spreewald. If you would like to add it manually, here is the step definition:

When /^I click on "([^\"]+)"$/ do |text|
  matcher = ['*', { :text => text }]
  element = page.find(:css, *matcher)
  while be...

Speed up large Cucumber test suites

Test suites usually grow over time as more and more development time is spent on a projects. Overall run-time and performance of Cucumber suites in turn increases, too.

You can use the very same way Henning suggested for speeding up RSpec some time ago.

Put the following into features/support/deferred_garbage_collection.rb

Before do
  DeferredGarbageCollection.start
end

After do
  DeferredGarbageCollection.reconsider
end

We...

New cards feature: Personal RSS feed that includes public and private cards

Your account profile now links to a personal RSS feed. This RSS feed contains the newest public and private cards for all your decks.

New cards feature: Explicit language declaration for syntax highlighting

Makandra cards will auto-detect the language used for syntax highlighting.

This auto-detection sometimes fails for short code snippets. In such cases you can explicitly declare the language for Github-style code blocks:

```css
body {
  font-size: 12px
}
```

Will turn into this:

body {
  font-size: 12px
}

To disable syntax highlighting entirely use the text language:

```text
I am nothing without pretend

...

Bundler: Fatal error and 'no such file to load -- net/https'

Today, I ran into trouble on a fairly fresh installed VM, running Ubuntu. I tried to bundle install and got this stacktrace:

Fetching gem metadata from https://rubygems.org/.Unfortunately, a fatal error has occurred. Please see the Bundler 
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks! 
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- net/https (LoadError)
	from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
	from /usr/li...

When overriding #method_missing, remember to override #respond_to_missing? as well

When you use method_missing to have an object return something on a method call, always make sure you also redefine respond_to_missing?.

If you don't do it, nothing will break at a first glance, but you will run into trouble eventually.

Consider this class:

class Dog
  
  def method_missing(method_name, *args, &block)
    if method_name == :bark
      'woof!'
    else
      super
    end
  end
  
end

This will allow you to say:

Dog.new.bark
=> "woof!"

But:

Dog.new.respond_to? :bark
=> false
```...

How to: Limit or disable textarea resizing in Chrome and Firefox

Consider this Sass:

.comment
  width: 320px;
  height: 240px;

Any textarea with the comment class will be sized 320 by 240 pixels. In WebKit browsers (Chrome, Safari, ...) or Firefox, this is only the initial size -- users can resize textareas to become bigger.

This is helpful to the user, but may be breaking your application layout in some cases.

If you want to disable it, don't introduce any proprietary CSS properties. Instead, set maximum width and/or height to the values of width and height:

.comment
  wi...

Cucumber: Calling multiple steps from a step definition

When refactoring a sequence of steps to a new, more descriptive step, you can use the steps method and Ruby's %-notation like this:

Given 'I have an article in my cart' do
  steps %(
    When I go the article list
    And I open the first article
    And I press "Add to cart"
  )
end

This way you can simply copy the steps over without any changes.

Warning: Apparently, steps processes its argument with the Gherkin parse...

Install rabbitmq plugins (e.g. management plugin) on Ubuntu 12.04

If you want to install rabbitmq plugins on Ubuntu 12.04 you can do this with:

/usr/lib/rabbitmq/lib/rabbitmq_server-2.7.1/sbin/rabbitmq-plugins

This binary is not in your default $PATH. Beause of this you have to give the full path.

Run specific version of bundler

You can specify the version of bundler to execute a command (most often you need an older version of bundler, but don't want to uninstall newer ones):

bundle _1.0.10_ -v
Bundler version 1.0.10

An example is rails 3.2, which freezes bundler at version ~> 1.0:

Bundler could not find compatible versions for gem "bundler":
  In Gemfile: rails (~> 3.2) was resolved to 3.2.0, which depends on bundler (~> 1.0)

Current Bundler version: bundler (1.13.6)

You can solve this with:

gem install bundler -v 1....

Rails 3.1 gives you free down migrations

In Rails 3.1+, instead of defining a separate up and down method you can define a single method change:

class AddComparisonFieldsToReport < ActiveRecord::Migration
  def change
    add_column :reports, :compare, :boolean
    update "UPDATE reports SET compare = #{quoted_false}"
    add_column :reports, :compare_start_date, :date
    add_column :reports, :compare_end_date, :date
  end
end

Migrating up works as expected:

b rake db:migrate
==  AddComparisonFieldsToReport: migrating ====================================
-- ad...

Setup your terminal to not scroll when there is new output

When you are scrolling up to investigate a test failure it is super annoying when the terminal scrolls back down whenever the running test outputs another line. Luckily you can disable this behavior:

  • Gnome terminal: *Edit -> Profile preferences -> Scrolling", uncheck Scroll on output
  • Terminator: Right click on terminal screen, Preferences -> Profile -> (for each profile) -> Scrolling, uncheck Scroll on output

Ruby 1.8.7-p370 released

It's the last bugfix release. We will get another year of security fixes, then no more patches.

Updated: Test a gem in multiple versions of Rails

Updated the card with our current best practice (shared app code and specs via symlinks).