Sun Java JVM/JRE on Ubuntu Linux

Note that you should disable the Java plug-in in your browsers after installation.

Ubuntu >= 12.04

Java 11

sudo apt install openjdk-11-jre-headless

Java 10

sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java10-installer

Java 8

You probably want to get rid of OpenJDK (which is installed by default and leads to bad RubyMine performance):

Use Sass without Rails

You don't need a Rails application to use Sass. Even when you're working on a static site you can generate your CSS through Sass.

  • Install Sass with sudo gem install haml
  • Create a folder sass in the folder, that stores your stylesheets, e.g. mkdir css/sass
  • In a separate terminal window, run sass --watch css/sass:css. This will watch your sass files for changes and rewrite stylesheets as required.

This even works on Windows.

Note about your .gitignore

You might want to change our [typical .gitignor…

Linked content

Adding Stroke to Web Text

Because they are vector, it would make sense if we could do things that other vector programs (e.g. Adobe Illustrator) can do with vector text, like draw a stroke around the individual characters. Well, we can! At least in WebKit

Create a valid RSS feed in Rails

This will show you how to create a RSS feed that the Feed Validator considers valid.

Note that RSS is a poorly specified format. Consider using the Atom builder to make an Atom feed instead. Write a note here if you do.

  1. Controller

Create a FeedsController to host the RSS feed. Such a controller is also useful to host other data feeds that tend to gather over the lifetime of an application, e.g. sitemap.xml.:

Linked content

JQuery CSS Emoticons Plugin

The CSS Emoticons plugin is a simple jQuery plugin (and stylesheet) that allows you to turn any text emoticons on the page into cute little smiling faces with pure CSS3 styling (no images whatsoever).

When sessions, cookies and Clearance tokens expire and how to change it

Expiration of Rails sessions

By default Rails sessions expire when the user closes her browser window.

To change this edit your config/initializers/session_store.rb like this:

ActionController::Base.session = {
  :key          => '...',
  :secret       => '...'
  :expire_after => 10.years

In older Railses the initializer is not available. Set the option in the environment.rb instead:

config.action_controller.session = {
  :key          => '...',
  :secret       => '...' ...

Strip carriage returns in submitted textareas

When submitting textareas, browsers sometimes include carriage returns (\r) instead of just line feeds (\n) at the end of each line. I don't know when this happens, and most of the time it doesn't matter.

In cases where it does matter, use the attached trait to remove carriage returns from one or more attributes like this:

class Note
  does 'strip_carriage_returns', :prose, :code

Here is the test that goes with it:

describe Note do

  describe 'before_validation' do...
Linked content

wmd - The Wysiwym Markdown Editor

WMD is a simple, lightweight HTML editor for blog comments, forum posts, and basic content management. You can add WMD to any textarea with one line of code. Add live preview with one line more. WMD works in nearly all modern browsers, and is now completely free to use.

Linked content

rhulse's rails-css-views at master - GitHub

This gem is designed to provide CSS views to Rails, and a process to concatenate and minify these files to one file for production.

Make box shadows look the same in IE and other browsers

The box shadows created rendered in IE by CSS3PIE look darker and are blurred differently than in browsers that render box-shadow natively.

If possible, try to be OK with this. If not, make an IE-only stylesheet that uses a different color and blur radius:

// Real browsers:
+box_shadow("0 4px 10px #bbb")

// IE with PIE:
+box_shadow("0 5px 15px #888")

We should try to package this solution in a neat way so we don't need different stylesheets.

See also this [cross-browser box-shadow comparison]…

Recursively remove unnecessary executable-flags

Sometimes files attain executable-flags that they do not need, e.g. when your Windows VM copies them over a Samba share onto your machine.

From inside your Rails project directory call regularly:

geordi remove-executable-flags

Runs chmod -x on Ruby, HTML, CSS, image, Rake and similar files.

This script is part of our geordi gem on github.

Hide the last bottom margin in a container

When you create e.g. a sidebar box that contains headlines and paragraphs, the final paragraph's margin in that box will create an undesired 'bottom padding' inside that box.

Here is a Sass mixin that you can apply to such boxes. It makes the last child's bottom margin disappear:

    margin-bottom: 0

Use it like this:

  p, table, ul
    margin-bottom: 1em

Internet Explorer (fix)

Does not work in versions of <IE8

Your best bet is to expli…

Linked content

Get rid of US keyboard layout

> Keyboard layout reverting to US on (every) reboot

> I found the same problem, but only on my wife's account. I'd set her keyboard layout to UK through Gnome preferences and every time the US layout would reappear and be selected frustratingly.\
> It turned out that on the gdm login screen her choice of keyboard layout in the discreet option bar at the bottom of the screen was set to US. That was then overriding the Gnome layout preference.

> Selecting the appropriate keyboard layout on the next login solved the…

Change the color of a <hr> in all browsers

The following Sass will do it:

  color: #ddd
  background-color: #ddd
  border: none
  height: 1px
Linked content

mezzoblue's PaintbrushJS at master - GitHub

PaintbrushJS is a lightweight, browser-based image processing library that can apply various visual filters to images within a web page.

Autofocus a form field with HTML5 or jQuery

In Webkit you can use the HTML5-attribute autofocus:

= form.text_field :title, :autofocus => 'autofocus'

Here is a jQuery fallback for browsers that don't speak HTML5:

var Autofocus = {

  supported: function() {
    return 'autofocus' in document.createElement('input');

  fake: function() {

  extend: function() {
    Autofocus.supported() || Autofocus.fake();



Common Screen Resolutions

Optimize for

  • Notebook: 1280x800 (many consumer notebooks)
  • Netbook: 1024x600
  • Desktop: 1440x900 / 1680x1050 (19"- und 22"-Widescreen-TFTs)
  • iPad: 768x1024


  • 1280x800 (13.3"-15.4", 16:10)
  • 1440x900 (15.4", 16:10)
  • 1680x1050 (15.4"+, 16:10)
  • older notebooks cf. Desktops (1024, 1280, …)


  • 1440x900 (19", 16:10)
  • 1680x1050 (22", 16:10)
  • 1920x1080 (23", 16:9)
  • 1920x1200 (24", 16:10)
  • 1024x768 (17", 4:3)
  • 1280x1024 (19", 5:4)
  • 1600x1200 (21", 4:3)


  • 720x480 (7")
  • 1024x600 (8.9")

Cucumber Webrat steps

Most of these will not work in newer projects because these use the Capybara/Rack::Test combo in lieu of Webrat.

Find input fields

Then /^there should be a "([^"]+)" field$/ do |name|
  lambda { webrat.current_scope.send(:locate_field, name) }.should_not raise_error(Webrat::NotFoundError)

Then /^there should be no "([^"]+)" field$/ do |name|
  lambda { webrat.current_scope.send(:locate_field, name) }.should raise_error(Webrat::NotFoundError)

Find html content

Then /^I should see "([^\"]*)...
This website uses cookies to improve usability and analyze traffic.
Accept or learn more