Ruby: How to camelize a string with a lower-case first letter

If you want to do JavaScript-style camelization, ActiveSupport's String#camelize method can actually help you out. Simply pass a :lower argument to it.

>> 'foo_bar_baz'.camelize
=> "FooBarBaz"
>> 'foo_bar_baz'.camelize(:lower)
=> "fooBarBaz"

Listening to bubbling events in Prototype is easy

If you come across an (older) application that is using Prototype instead of jQuery, you may often see events bound to single elements only, like this:

$('foo').observe('change', updateThings);
$('bar').observe('change', updateThings);
$('baz').observe('change', updateThings);

If you are calling only one method in each case, this is unnecessarily ugly. Also, when your page contents have been replaced via AJAX (like sections of a form after choosing something), those event hooks will no longer wo...

Test whether Perfect Forward Secrecy (PFS) is enabled on a server (using OpenSSL)

Use the following command to test if a server (in this example: makandra.com on port 443) uses Perfect Forward Secrecy (PFS):

openssl s_client -connect makandra.com:443 -cipher ECDHE-RSA-RC4-SHA

You should see something like the following:

~ > openssl s_client -connect projecthero.com:443 -cipher ECDHE-RSA-RC4-SHA
CONNECTED(00000003)
depth=1 O = AlphaSSL, CN = AlphaSSL CA - G2
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/C=DE/OU=Domain Control Va...

IE10 / IE11 Metro mode: How to switch tabs or show the address bar

Internet Explorer on Windows 8 and 8.1 is available in a "Desktop version" and the metro version which is designed for touch devices. \
When using IE Metro with a mouse (e.g. via BrowserStack), controls such as the tab bar or address bar will disappear after a little while.

To show them again, right-click anywhere in the page (except on links, etc).

O_o

Mouse wheel + Shift key = horizontal scrolling

On Ubuntu, you can scroll horizontally with your mouse wheel when holding the Shift key while scrolling.

It does not work in all applications, but many support it.

Count number of weekdays between two dates

If you need to quickly find out the number of weekdays (Monday to Friday) between to given dates, try this:

require 'date'
a = Date.parse "11.04.2014"
b = Date.parse "31.12.2014"

(a..b).count {|date| (1..5).include?(date.wday) }