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"

Remove duplicate lines from a text file

You can use this shell command:

uniq -u input.txt output.txt
External content

The Skinny on CSS Attribute Selectors

Good guide to different ways you can write CSS selectors that select elements by their attribute values.

Truncate files to zero length

This will reduce the filesize of foo and bar to 0 bytes:
truncate -s0 foo bar

If the files do not exist they will be created.

You can use this to easily truncate your application’s log files:
truncate -s0 log/*.log

Solving "cannot remove Object::ClassMethods"

Most likely you run rake and your code is causing an exception which is not the one shown in your terminal.

Rails tries to catch this exception and clean up constants but – while it’s still booting up – fails on this which causes another exception:

rake aborted!
cannot remove Object::ClassMethods

Running rake with the --trace parameter will give you no love; the backtrace is useless in most cases.

Try these approaches:

  1. Check if there is a helpful error message

  • Have…

When Rails does not recognize Rake tasks in lib/tasks

When you put a Rake task into lib/tasks, but running it fails with…

Don't know how to build task name:of:task

… does your Rake task’s filename end in .rb? It needs to end in .rake instead.

Make an HTTP request to a machine but fake the hostname

Consider you have a website vhost listening to, redirecting all incoming requests that do not talk about the configured hostname (this is often used to redirect users to when entering only

If you want to make a request to that site’s web server without actually talking to (e.g. because this is a load balancer’s address but you want to access one specific machine), you cannot just request or localhost as the above vhost will redirect…

External content

Runaway Regular Expressions: Catastrophic Backtracking

This article explains why some regular expressions take years to match against certain strings. A common culprit are nested repetition operators like in (x+x+)+y.

External content

How Non-negotiable Features Kill Software Products

features are pre-sold without any option to negotiate what’s important and what may be left out, you inevitably end up with too much complexity. Such pre-sold features not only tie your hands, but the client is also not able to change what he needs over time.

Selenium WebDriver 2.5.0, 2.6.0 fails when selecting options from select boxes

We are consistently having trouble with selenium-webdriver > 2.5.0 where whenever we try to select an option from a <select> Capybara complains:

No such option 'Foo' in this select box. Available options: 'Foo', 'Bar', 'Baz' (Capybara::OptionNotFound)

This seems to happen with both old and new versions of Firefox. Our workaround so far is to freeze the gem at version 0.2.2.

Fixing Homebrew "Permission denied" issues

When installing your first formula, Homebrew may complain about not being able to access certain directories. The easiest solution to this is:

chown <username> /usr/local/Cellar /usr/local/share # create these directories if they do not exist

Then sudo brew install abc and you’re going.

External content

What's My DNS? Global DNS Propagation Checker is an online service that allows you to instantly perform a DNS lookup to check a hostnames current IP Address and other DNS information against a selection of random name servers around the world. This is especially useful to check the current state of DNS propagation after making changes to your domains zones.

External content

sstephenson/execjs - GitHub

ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.

External content

Git: List remote branches

Sometimes you may need to figure out what branches exist on a remote repository so you can pull them down and check them out, merge them into your local branches, etc. You can see the remote branches by saying

git branch -r

Or, if you want to see both local and remote branches, you can say

git branch -a

Setup inaction_mailer

Add to Gemfile
group :development do
gem “inaction_mailer”

Set the action mailer delivery method to :inaction_file in your development.rb
config.action_mailer.delivery_method = :inaction_file

inaction_mailer will save the mails in .txt files within /tmp/sent_mails

Couldn't create database for ...

When you run rake db:create and get this error message

Couldn't create database for {"encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"project_development", "password"=>"topsecret"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)

make sure the user you have specified (root/topsecret) in your database.yml has access to MySQL. You can check this by running mysql -uroot -p.

Dealing with Solr's "404 Not Found" response

When your Solr seems to be started properly (a process is running with the correct data directory) but never responds properly and replies (via the API or web interface) with…
404 “Not Found”

… check if Solr’s log directory is actually writable for the user running it.

Disable output when using cURL

cURL makes a web request and shows you the response body.

You can redirect the response body to /dev/null just like for many other programs. But if you do that, cURL will display some short information about the request you are making:

$ curl > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 30865  100 30865    0     0   4793      0  0:00:06  0:00:06 --:--:-- 10199

If you wan…

We forked craken

We forked craken today and fixed one of the issues we had with new (>0.8.7) rake versions.

The craken:install rake task raised a “can’t convert Hash into String” error e.g. while deploying with Capistrano.

2785 cards