External content

Prism.js: simple, fast and lightweight syntax highlighting

Prism is a new lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s a spin-off from Dabblet and is tested there daily by thousands.

External content

Phusion Passenger 4 Technology Preview: Out-Of-Band Work – Phusion Corporate BlogPhusion Corporate Blog

The Out-of-Band Work feature allows one to perform arbitrary long-running work outside the request/response cycle without blocking HTTP clients. The primary use case is to run the garbage collector in between cycles so that your requests will finish faster because they will not be interrupted by the garbage collector.

RVM: Get rid of your system Ruby

If you worked with a system Ruby before switching to RVM, this system Ruby will be in your way when you switch between projects with/without RVM.

It's hard to get rid of your system Ruby entirely, but you can tell RVM to just use a given Ruby by default, e.g.:

rvm --default use 1.8.7

You need to re-open existing terminals for the changes to take effect.

Note that this will not actually remove the ruby package from your system, it just isn't used anymore.

Detect effective horizontal pixel width on a mobile device with Javascript

So you want to find out how many horizontal pixels you have available on a mobile device. This is super difficult because:

Customize tokenization of the MySQL FULLTEXT parser

The way MySQL's FULLTEXT tokenizer splits text into word tokens might not always be what you need. E.g. it splits a word at period characters.

Since the tokenizer has near-zero configuration options (minimum word length and stopwords list), you need to hack it. There are three options available.

Option 1: If you like pain

Write a Full-Text parser plugin in C.

Option 2: Make the problem go away


External content

Geocoding Strategies - Google Maps API

The attached article outlines considerations when choosing client-side vs. server-side implementations of the Google Geocoding APIs (geocoder, directions, not maps drawing). The main points are:

  • On the server side you only get a fixed daily request quota
  • On the client side the quota is per-client, so basically unlimited
  • When implementing APIs on the server-side, be aware that quota is measured by IP. When hosting in the cloud **you don't always know which other services might…
External content

daylerees/colour-schemes · GitHub

Awesome color schemes for RubyMine, Sublime Text 2 and other editors.

To install the themes into your Rubymine, copy intellij-themes/*.xml from the repository to your local ~/.RubyMine40/config/colors. Then restart RubyMine.


Geordi: run a capistrano task on all stages

Geordi now has a script that runs capistrano with all known deploy targets (i.e. staging, production…).

Use with

geordi capistrano deploy:migrations


geordi capistrano deploy

The abbrevation geordi cap ... works as well.

Git: How to stash with a custom message

If you say git stash, your stashed changes will be identified with an automatically generated message:

$ git stash
Saved working directory and index state WIP on master: 77af0df Merge branch 'production'

While this is okay to temporarily stash away stuff, you may want a better identifier for your changes so you can find them more easily if you stash often.
Of course, there is a way to do it with git:

$ git stash save doing crazy things
Saved working directory and index state On master: doing crazy things

Note that you n…

How to get the hostname of the current machine in Rails or a Ruby script

Use Socket.gethostname. So for a machine whose hostname is "happycat", it will look like this:

>> Socket.gethostname
=> "happycat"

That should work right away for your Rails application. For plain Ruby, you first need to do:

require 'socket'

If you don't want to use Socket for some reason, you can still just use the hostname command, at least on non-Windows machines. Keep in mind that you need to remove trailing white space from the result of the system call.

>> `hostname`
=> "happycat\n"
>> `hostname`.stri...

Fix error: undefined method `desc' for #<Foo::Rake::Taskx1234>

Upgrade the offending gem. If you cannot or don't want to upgrade, lock rake to 0.8.7.

Autoplay HTML5 audio in Chrome for Android, Mobile Safari in iOS

  • Mobile browser's ignore the autoplay attribute on <audio> and <video> elements. Stupid reasons include saving mobile bandwidth on behalf of the user and/or securing app store sales.
  • Audio and video elements will only play as the result of a user interactions (click, touch).
  • A workaround is to have a "start button" in your application that loads and plays an initial sound.
  • You can now play further sounds without user interaction by changing the source on the same <audio> element.

I tested this on Chrome for Android. The int…

Error: "sylogd: /var/log/authlog : no such file or directory" but the file exists

If you get a message like this:

Jan 21 13:42:38 foobar syslogd: /var/log/authlog : no such file or directory

But you are sure the file exists and it have the correct permissions:

# example for Solaris 9
-rw-r--r-- 1 root sys 8,0K 21. Jan 13:51 /var/log/authlog

Then you perhaps have a trailing whitespace after /var/log/authlog in the /etc/syslog.conf.

Note: Use TAB to separate log components from log file names in Solaris. Because spaces do not work.

Using Apache Benchmark (ab) on sites with authentication

Apache HTTP server benchmarking tool (ab) is a nice tool to test performance on sites delivered by HTTP. If the site you're about to test is placed behind a login, follow these steps to successfully use ab on it.

  1. Open the site to test in the browser of your choice. Do not login yet.
  2. Use developer tools to show all cookies used by the site. (Chrome: Ctrl+Shift+i, open the 'Resources' tab and click on the site below 'Cookies' on the left. Firefox: Right-click on the site, open 'We…

Ruby: How to ensure a Tempfile's extension

If you use Tempfile and pass your own filename containing an extension, it will just be consumed by the Tempfile's filename:

=> "/tmp/foobar.xlsx20130115-19153-4ykpwm-0"

If you want to keep the file extension, pass filename and extension as an array:

>>[ 'foobar', '.xlsx' ]).path
=> "/tmp/foobar20130115-19153-1xhbncb-0.xlsx"

Consul 0.5.0 is faster for admins, allows to define multiple powers at once

When calling a scope like current_power.user?(user), Consul will no longer trigger a query if the users power selects all records (SELECT * from users). This should make such checks much faster for users who can access many records, like admins.

You can now define multiple powers at once:

power :users, :updatable_users, :creatable_users do

Fix warning: No secret option provided to Rack::Session::Cookie

You will get this when you are using the latest version of Rails with a recent version of Rack:

SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.

The warning is caused by Rails calling Rack incorrectly. [It is unclear](https://github.c…

3313 cards