Subscribe to Rails security mailing list without Google account

The Ruby on Rails security list archive can be found here:

You can subscribe to this mailing list without a Google account by pasting this URL into your browser (after replacing the email address obviously).
                                                                       ^^^^^^^^^^^^^^^^^^^^^ <- Change this
External content

Redactor WYSIWYG html editor

New WYSIWYG editor that claims to be lighter and prettier than TinyMCE and CKEditor. Has some Rails integration, too.

News flash: Absolute CSS positioning on opposite sides is not a problem

Back in the old days, we couldn't do something like that:

.foo {
  position: absolute;
  bottom: 0;
  /* This was bad: */
  left: 10px;
  right: 10px;

Why? Because IE5 and IE6 (which a majority of people used back then) failed horribly trying to render it.

I've now checked if this is still an issue with any browser that's not from the stone age. \
Turns out all is well – except if you have to support IE6 and below, but then you're in some other kinds of trouble.

It works in all sane browsers, and Internet Explorer 7, 8…

How to: Build a "generic observer" widget for the awesome window manager

If you want a widget for awesome that runs a command regularly (every X seconds) and puts the output into your awesome panel, this is for you.

Put the code below into your ~/.config/awesome/rc.lua. It supplies two methods:

  • execute_command will run a command and return its output. Multiple lines will be joined into one line. The code is from the awesome wiki.
  • widget_with_timeout is a method that takes a command to run and a timeout in secon…

Duplicate a git repository with all branches and tags

In order to clone a git repository including all branches and tags you need to use two parameters when cloning the old and pushing to the new repository respectively:

git clone --bare
cd old-repo
git push --mirror

Of course, the URLs to your repository might look different depending on the protocol used, username required, etc.
For a user git using the git protocol, it could be

Clean up application servers when deploying

Our development process makes us deploy very often. As the number of releases grows, junk clogs up the hard drive of our application servers:

  • Old release code
  • Old tmp folders with compiled view templates etc.
  • Precompiled assets (Javascripts, images…) that no longer exist. When using the asset pipeline, Capistrano will symlink the public/assets directory to shared/assets. This is cool since we can still serve previous assets after a new release, in the window where browser caches might still have references to old assets. But i…

Launch Gnome disk utility from command line

No chance you would have ever guessed it…

sudo palimpsest

LibreOffice Calc: Reset positions of split dividers

To reset the position of split dividers, drag all the dividers out of the screen. Then turn off splitting and turn it on again.

How to find out which type of Spec you are

When you need to find out in which kind of spec you are during run-time, it's definitely possible. It's a lot easier in RSpec2.

For example, consider this global before block where you'd want to run some code for specific specs only:

config.before do
  # stuff
  # more stuff

RSpec 2

If you want to run such a block for a specific type of specs, you can use filters:

config.before do
  # stuff
  # more stuff  ...

Quick git contributors list

git shortlog -s -n
-n, –numbered
Sort output according to the number of commits per author
-s, –summary
Suppress commit descriptions, only provide commit count

Example output for spreewald:

60  Tobias Kraze
12  Henning Koch
 7  Dominik Schöler
 6  Thomas Eisenbarth
 5  Martin Straub
 3  Minh Hemmer
 2  Alex McHale
 1  Manuel Kallenbach
 1  Andreas Robecke
External content

How to remap keys in Ubuntu

Good article that tells you how to change behavior of certain keys via xmodmap (with the help of exv if you need to find out the keycode).

Ruby Scripts: Select the Ruby version in the shebang

As Bill Dueber has on his blog, you can call rvm in the shebang to select a Ruby version like this:

 #!/usr/bin/env rvm 1.9 do ruby

Standard arguments to do apply, see $> rvm help do.

How to clear cookies in Capybara tests (both Selenium and Rack::Test)

Capybara drivers will usually delete all cookies after each scenario. If you need to lose cookie data in the middle of a scenario, you can do this:

browser = Capybara.current_session.driver.browser
if browser.respond_to?(:clear_cookies)
  # Rack::MockSession
elsif browser.respond_to?(:manage) and browser.manage.respond_to?(:delete_all_cookies)
  # Selenium::WebDriver
  raise "Don't know how to clear cookies. Weird driver?"

Inherit without Single-Table-Inheritance (STI) in ActiveRecord

You have multiple options:

  1. Just don't have a type column. All STI magic will be disabled automatically.
  2. If you have a type column but want to use it for something else (WAT?), you can set self.inheritance_column = :_non_existing_column in the class definition
  3. (Untested) In the parent class, set self.abstract_class = true

This technique is useful to implement form models / presenters, where you want all the goodness of Ac…

How to find out if you are in Cucumber or in RSpec

Sometimes you need a piece of code to do something different for specs than for features. If you don't have separate environments, you can't check your Rails.env.

I managed to distinguish between specs and features by asking Capybara:

if defined?(Capybara) and Capybara.respond_to?(:current_driver)
  # you're in a Cucumber scenario
  # you're probably in a spec

You could omit the defined?(Capybara) condition, if you are sure that Capybara is always defined when that code is being called.

Using Thin for development (with SSL)

Note: These instructions are for a quick per-project setup and may require you to change code. If you generally need SSL for development, you probably want to use Passenger.

  1. Create a directory .ssl in your home directory. Go there and create a self-signed certificate. It is important to enter localhost.ssl as Common Name when asked. This is to mak…
3447 cards