Search_spinner Cross_grey Magnifier

Search syntax

  • Search for repeating cards with repeats:yes
  • Search for unfinished cards with unfinished:yes
  • Search for cards in a certain topic with topic:"name"
  • Search for phrases with "a phrase"
  • Exclude a word from search: -word
  • Exclude a phrase from search: -"a phrase"
  • Exclude a topic from search: -topic:"name"
External content

TrackDuck: Visual feedback for web design and development

Service that you can integrate for user feedback.

Super-simple integration: Add a <script> tag to your layout, done.

It will then add a button to the bottom right of your application. When a user clicks it, they can take a screenshot and leave a message. The screenshot then appears in TrackDuck’s interface for you to work off.

Current pricing is 9 USD per month for the smallest tier (1 project).

A solid and unobtrusive plugin for form field placeholders

jquery-placeholder is a simple jQuery plugin that enables form placeholders in browsers that do not support them natively, i.e. IE < 10.


  • Works in IE6.
  • Automatically checks whether the browser natively supports the HTML5 placeholder attribute for input and textarea elements. If this is the case, the plugin won’t do anything. If @placeholder is only supported for input elements, the plugin will leave those alone and apply to textareas exclusively. (This is the case for Safari 4, Opera 11.00, and possibly other browsers.) …
External contentRepeats

What Ruby’s ||= (Double Pipe / Or Equals) Really Does

||= and &&=

a ||= b
a || a = b

a &&= b
a && a = b


a += b
a = a + b

a -= b
a = a - b

# Other operators, e.g. Array#| (union)
ary1 = ['a', 'b', 'c']
ary2 = ['c', 'd', 'a']

ary1 |= ary2
ary1 = ary1 | ary2
# => ['a', 'b', 'c', 'd']
Repeats Most comfortable and free favicon generator

Eduardo Russo was tired of complex favicon creation and created his own favicon generator. It’s really easy and allows a lot of image editing before rendering the favicons, in all needed sizes, formats and with the HTML needed to include them!

Unfreeze a frozen ActiveRecord

You can freeze any Ruby object to prevent further modification.

If you freeze an ActiveRecord and try to set an attribute you will an error like this:

can't modify frozen hash

This is because ActiveRecord delegates #freeze to its attributes hash.

You can unfreeze most Ruby objects by creating a shallow copy of the frozen object by calling #dup on it:

user = User.find(3)
unfrozen_user = user.dup

Notes for Rails 2 users —————–…

Ruby: How to grow or shrink an array to a given size

If you want to grow a Ruby Array, you might find out about #fill but it is not really what you are looking for. [1]
For arrays of unknown size that you want to grow or shrink to a fixed size, you need to define something yourself. Like the following.

Array.class_eval do

  def in_size(expected_size, fill_with = nil)
    sized = self[0, expected_size]
    sized << fill_with while sized.size < expected_size


Use it like this:

>> [1, 2, 3].in_size(5)
=> [1, 2, 3, nil, nil]    ...

PostgreSQL vs MySQL: How to update using a join

When performing an UPDATE statement, you may want to join a table to update from. It works differently in MySQL and PostgreSQL.


UPDATE profiles
INNER JOIN users ON profiles.user_id =
SET public = users.visible


UPDATE profiles
SET public = users.visible
FROM users
WHERE profiles.user_id =

RubyMine: Scratch files

There are times when you have a chunk of text that you want to do something with, e.g. replace something on it, or quickly edit it.

While you can open your favorite non-RubyMine editor for this, there is also a plugin: Scratch.

It allows RubyMine to open temporary files (actually they are saved, but somewhere inside the plugin’s directory) so you don’t need to switch to a text editor like gEdit that works differently and may not even offer what you are used to.

Install it like this:

  1. Open…

Make timestamp of dmesg in Ubuntu human readable

dmesg shows the kernel ring buffer containing low-level system messages.
Per default, dmesg shows a timestamp:

12:59:26 fnordomator ~ > dmesg | tail
[101925.211846] usb 2-1.1: USB disconnect, device number 16
[110486.855788] usb 2-1.1: new high-speed USB device number 17 using ehci_hcd

If you’re a human, use dmesg -T to print the timestamp human readable:

12:59:31 fnordomator ~ > dmesg -T | tail
[Di Apr 21 12:43:16 2015] usb 2-1.1: USB disconnect, device number 16
[Di Apr 21 15:05:57 2015] usb 2-1.1: new hig...

Faking and testing the network with WebMock

An alternative to this technique is using VCR. VCR allows you to record and replay real HTTP responses, saving you the effort to stub out request/response cycles in close details. If your tests do require close inspection of requests and responses, Webmock is still the way.

WebMock is an alternative to FakeWeb when testing code that uses the network. You sh…

Make "rake notes" learn about Haml, Sass, CoffeeScript, and other file types

Rails comes with a Rake task notes that shows code comments that start with “TODO”, “FIXME”, or “OPTIMIZE”.

While it’s generally not good practice to leave them in your code (your work is not done until it’s done), in larger projects you will occasionally have to use them as other parts of the application that you depend upon are not yet available.
To keep track of them, run rake notes. Its output looks something like this:

$ rake notes

Rubymine: Code folding

Code folding is a very useful feature to me. It gives me a quick overview over a file and keeps me from scolling like a hamster in its wheel.

Keyboard shortcuts:

Collapse/expand current code block
strg -/+
Collapse/expand the whole file
strg ctrl -/+

When diving into Cucumber features or huge Ruby classes, I usually collapse all and the gradually expand what I need.

PSA: "index: true" in Rails migrations does not work as you'd expect

Several Rails migration methods accept index: true as an option to create an index. In some cases, this silently does not work. Know exactly what you are doing, or do not use it and use add_index instead.


Consider the following migration.

class CreateExamples < ActiveRecord::Migration
  def change
    create_table :examples do |t|
      t.references :category, index: true
      t.boolean :positive, index: true
      t.integer :number_of_participants, index: true


[Bugreport] Symbolized Strings Break Keyword Arguments in Ruby 2.2

TL;DR Under certain circumstances, dynamically defined symbols may break keyword arguments in Ruby 2.2. This is fixed in Ruby 2.3-dev.

Specifically, when
- there is a method with several keyword arguments and a double-splat argument (e.g. def m(foo: 'bar, option: 'will be lost', **further_options))
- there is a dynamically created Symbol (e.g. 'culprit'.to_sym) that is created before the method is parsed
- the method gets called with both the option and a culprit keyword argument

then the option keyw…

Using mime types with send_file

When using send_file (for example for attachments of any kind), make sure your application knows the correct mime types so that all browsers can handle the files. It is much more convenient for users if they can decide to open a file directly instead of having to save it first.

For Rails >= 3.2

Simply put your mime types in config/initializers/mime_types.rb. send_file will take care of everything else.

For Rails < 3.2

Put your mime types in config/initializers/mime_types.rb. Additionally, tell send_file to use them (for ex…

External contentRepeats

Ruby facets

Ruby Facets is the premiere collection of general purpose method extensions and standard additions for the Ruby programming language.


RSpec: Tagging examples and example groups

In RSpec you can tag examples or example groups with any tags you like simply by saying

describe ReportCreator, slow: true do
  # ..

describe ReportCreator do
  it 'generates reports', slow: true do
    # ...

You can then only run examples with these tags.

rspec --tag slow
rspec -t slow

# Using the parallel_tests gem
rake "parallel:spec[,,--tag slow]"

Or you can run all examples except the ones with a certain tag:

rspec –tag ~slow # note the ~
rspec -t ~slow

Using the parallel_tests gem

rake “par…


ActiveRecord: Automatically remove join records on has_many :through associations

# Given the following models

class Image < ActiveRecord::Base
  has_many :album_image
  has_many :albums, through: :album_images

class Album < ActiveRecord::Base
  has_many :album_image
  has_many :images, through: :album_images

class AlbumImage < ActiveRecord::Base
  # Join model
  belongs_to :album
  belongs_to :image

Destroying a record in this setup will only remove the record itself, and leave orphaned join records behind.

image = Image.last
image.destroy # removes only the image record,
# but…

2786 cards