View

Resque: Clearance authentication for dashboard

Resque comes with its own dashboard (Resque server) that you can mount inside your Rails 3 application with

#config/routes.rb:

require 'resque/server'

My::Application.routes.draw do
  # ...

  mount Resque::Server => '/resque'
end

Unfortunately, since this bypasses the filters in your ApplicationController, everyone can access this dashboard now (unless you have some Rack-based authentication in place, like Devise).

If you're using …

How to hide your selenium browser window with "headless"

Note: While the solution in this card should still work, we prefer another solution now: Hide your Selenium browser window with a VNC server.


If you would like to hide the annoying selenium browser window that always gets the focus and prevents you from working, you can use the headless gem. This note provides some instructions how you can get it to work with your cucumber accepta…

Rails 3: Sending tempfiles for download

When you create a temporary file (e.g. to store a generated Excel sheet) and try to send it to the browser from a controller, it won't work by default. Take this controller action:

class FoosController < ApplicationController
  def download
    file = Tempfile.new('foo')
    file.puts 'foo'
    file.close
    send_file file.path
  end
end

Accessing this controller action will usually raise a 404 not found in the browser and the Apache log will say:

The given path was above the root path: xsendfile: ...

How to type accented characters on keyboard layouts without dead keys

Ubuntu comes with keyboard layouts like "Germany Eliminate Dead Keys", which are practical for programming.

If you need to type accented characters with such a layout, make sure to configure a Compose key. You can then look up which compose combo will produce the character you need.

E.g. you can type "á" by pressing Compose, ´, a.

Fix for: Your Firefox profile cannot be loaded. It may be missing or inaccessible.

If you use Selenium and Launchy to open web pages, you might run into an error saying "Your Firefox profile cannot be loaded. It may be missing or inaccessible.".

This happens because Launchy tries to use your Firefox running the web driver to open the page.

For Launchy < 0.4.x, as a workaround you can set an environment variable

export LAUNCHY_BROWSER=`which google-chrome`

For newer Launchys you also need to set:

export BROWSER=`which google-chrome`

If you want to do this in a ruby script, you can say

chrome_path ...

How to remap your caps lock to a second Escape key

When have you last used your caps lock key? On purpose? Right…

In Gnome
Make it an additional ESC key by going to System -> Preference -> Keyboard -> Layouts -> Options -> CapsLock key behavior and select "Make CapsLock an additional ESC".

On recent Ubuntus this option was removed so you have to resort to using dconf.

dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']"
In any X11 window manager
Simply run `setxkbmap …

Running the Awesome window manager within Gnome

Note: Consider using MATE instead of Gnome 3 on newer system

Awesome is a very good tiling window manager that provides neat features like automatic layouting of windows, good multi-display support with per display workspaces and more. Unfortunately, it is only a window manager, and lacks a lot of Gnome's conveniences like the network manager, application menus, automatic updates etc.

Fortunately, Gnome allows you to selectively replace only the window manager, so you get all of Gnome'…

How to enlarge a VirtualBox VDI disk file

VirtualBox does not offer anything for this task – you need to do it yourself. It's not that hard:

Get more disk space

  1. Add an extra virtual hard disk to the machine with the disk size you want to achieve.
  2. Get a Linux live CD (like the Ubuntu live image) that offers fdisk, dd and gParted.
  3. Boot the guest from the CD, open a terminal (on the guest, not the host!) and become root: sudo su
  4. fdisk -l to see the disk information. \
    There should be one drive with some partitions and one without any….
Linked content

Disable text selection on iOS and Android devices

When you double-tap a string of text on an iPhone or iPad a complicated context menu for copying and pasting will appear. This can confuse unexperienced users.

Use the Javascript hack below to disable text selection on mobile devices:

// Deactivating distracting Text Selection:
// from: http://stackoverflow.com/questions/1794220/how-to-disable-mobilesafari-auto-selection
$.fn.extend({
  disableSelection : function() {
    this.each(function() {
      this.onselectstart = function() {
        return false;
  ...

Disable Dell U2410 beeping sound

The first thing to do with any new U2410 should be to disable the incredibly annoying beep when pressing any monitor button. Here is the fastest way to achieve that:

  • OSD button (above the power button)
  • Menu
  • 2 × Up (You should be at “Other Settings” now)
  • Right
  • 4 × Up (“Button Sound”; the “Power Save Audio” entry is usually grayed out, so this is 1 beep less than from above.)
  • Right
  • Down
  • Tick

Do it this way or your colleagues will stand at your desk after the 12th beep, ready to smack you.

Getting non-Aero toolbars for Thunderbird 5 on Windows 7

Thunderbird 5 brings a custom chrome on Windows Vista/7 that uses translucent Aero decorations on toolbars and menubars. Here is how to restore solid backgrounds if you don't like it.

Put the following into chrome\userChrome.css in your Thunderbird profile directory:

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
window {
  background-color: -moz-dialog !important;
}

(Re-)start Thunderbird afterwards.


If you need more info on where the userChrome.css is suppose…

Check whether an element is visible or hidden with Javascript

jQuery

You can say:

$(element).is(':visible')

and

$(element).is(':hidden')

jQuery considers an element to be visible if it consumes space in the document. For most purposes, this is exactly what you want.

Native DOM API

Emulate jQuery's implementation :

element.offsetWidth > 0 && element.offsetHeight > 0;

Prototype

Don't use Element#visible(), it just checks if a CSS attribute display: none ex…

Be careful when closing expanded stories in Pivotal Tracker

When you open up a story to only have a look at it, close it by pressing the "Cancel" button (or Esc key).

Clicking the arrow in the top left is the same as pressing the "Save" button. If someone changes the story description in the meantime you will overwrite their changes with everything you see, even if you did not change anything. If you only want to take a peek, prefer to hover the speech bubble icon.

If your story gets shotgunned and you notice it, you are lucky – and you may be able to get your changes back. Open up the his…

Test that a string of text is (not) linked in Webrat or Capybara

The step definition below allows you to write:

Then I should see a link labeled "Foo"
But I should not see a link labeled "Bar"

Webrat

Then /^I should( not)? see a link labeled "([^"]*)"$/ do |negate, label|
  expectation = negate ? :should_not : :should
  response.send(expectation, have_selector("a", :content => label))
end

Capybara

Then /^I should( not)? see a link labeled "([^"]*)"$/ do |negate, label|
  expectation = negate ? :should_not : :should
  page.send(expectat...

Run Selenium tests in Chrome instead of Firefox

Here is how to switch your Selenium to Chrome:

  1. Make sure you've got a recent version of chromedriver in your $PATH

  2. Register Driver:

Create a file features/support/capybara.rb with the following content for recent version of Capybara:

Capybara.register_driver :javascript do |app|
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

If you have an older Capybara version you need to say:

Capybara.javascript_driver = :selenium

Cap...

Force Google Chrome to run in English on Linux

If you need Google Chrome to run in English, and your system locale is a non-English one, you have two options:

  • Switch your system to an English locale
  • Head over to /opt/google/chrome/locales/ and remove any .pak files except those starting with “en”. They reappear when Chrome gets updated.

This may help you running your Selenium tests using the Chrome driver on applications that choose the language from what the browser sends as preferred language (which Chrome guesses from your system locale).

Mark up text in Balsamiq Mockups

When you edit text in Balsamiq Mockups, you can define inline styles like this:

Bold Some *bold* text
Italics Some _italic_ text
Blue underlined hyperlink Some [linked] text

Note that most Balsamiq widgets display with a bold font by default, so you won't usually see a difference when a piece of text is explicitly marked up as bold.

Linked content

Files open with an error "the location is not a folder" after installing XFCE

When using gnome-open (i.e. double-clicking a file, telling to browser to open a download, etc.) on Ubuntu you may get this error:

The location is not a folder.

It's due to the exo-utils package which does not play nice with gnome-open. You can fix the problem by uninstalling it:

sudo apt-get remove exo-utils

Note that this may also uninstall XFCE tools like xfce4-terminal or thunar (XFCE's directory browser). If you want to keep them, [try anot…

This website uses cookies to improve usability and analyze traffic.
Accept or learn more