View

Setup an Ubuntu mirror that enables local release upgrades

Setup the mirror by following the steps described here.

If you want to enable OS upgrades using do-release-upgrade make sure you include $release-proposed packages in the mirror script, e.g., precise-proposed. Additionally, you have to add main/dist-upgrader-all to the $section in your script as debmirror silently ignores some directories.

I attached our modified script to include current releases

Enable Ubuntu release upgrade from the local mirror ————————————–…

Carrierwave: Auto-rotate tagged JPEGs

Modern cameras often produce JPEGs that have a "I should be rotated 90° to the left" flag. If you process such pictures using Carrierwave this will be ignored and you'll end up with a wrongly rotated image.

Fortunately, this is easy to fix:

In your Uploader, add

process :auto_orient # this should go before all other "process" steps

def auto_orient
  manipulate! do |image|
    image.tap(&:auto_orient)
  end
end

Note: You can add the process :auto_orient outside of all your version blocks and it will apply…

query_diet now support Rails 3

Installation differs slightly from older versions, please check the README.

External content

Keyboard Navigation Plugin for Safari, Chrome and Firefox with a rich feature set

gleeBox is an experimental project that takes a keyboard-centric approach to navigating the web. It provides alternatives to actions that are traditionally performed via the mouse. Some of these are radically more efficient than using a mouse, some not so much. In all cases, they are mostly meant for keyboard and command line lovers.

Gleebox is a terrific plugin that makes navigating through webpages a wink. It even allows for selecting by jQuery selector.

Firefox: Inspecting mixed content warnings (and how to enable them)

Having your site run on SSL is worthless when you include content over an unsafe connection (HTTP).

Here is how to hunt down mixed content with Firefox.

How to enable mixed content alerts

If your Firefox does not warn you about mixed content on pages (mine did not), you can enable it again:

Visit about:config and search for security.warn_viewing_mixed. If it's set to false, set it back to true again.

Seeing which URLs are fetched from unsecured connections

Firefox 16+ will show you mixed content in its "Web Co…

External content

CSS3 Animated Loading Bar

Shows how to implement an animated progress bar in pure CSS, without animated GIFs, Javascript or Flash.

How to set the default monospace font on Xfce (Xubuntu)

While you can set your own font in your terminal or other tools, it will not change the default "Monospace" font that some applications use.

To change that, edit ~/.fonts.conf and add settings for the "monospace" family. Here is how it looks on my machine now:

```

monospace DejaVu Sans Mono

External content

Writing Fast, Memory-Efficient JavaScript

JavaScript engines such as Google’s V8 (Chrome, Node) are specifically designed for the fast execution of large JavaScript applications. As you develop, if you care about memory usage and performance, you should be aware of some of what’s going on in your user’s browser’s JavaScript engine behind the scenes.

Get all associations of an ActiveRecord class

YourClass.reflect_on_all_associations.map(&:name)

Get the class name by calling class_name, or the type of the association (belongs_to, has_many,…) by calling macro

Taming icon fonts for use in Rails views

Icon fonts like Font Awesome are infinitely scalable, look great on high-DPI displays and will give your app a modern look.

However, icon fonts can be very awkward to use compared to raster icons. Elements are given icons by giving them a special class like icon-plus or icon-home:

<span class="icon-plus">Create</span>

The icon font's stylesheet will then recognize this class and insert the icon as the element's :before style.

In practice, this pattern will give you a lot of hea…

Rails 2.3.x sometimes renders localized views with the wrong content type

Under certain (unknown) circumstances, Rails will give localized files an invalid content-type in the Response header. For me, after requesting corporate_information and rendering corporate_information.de.html.haml, Rails sent a content-type of de.html instead of the expected text/html.

There are some discussions on this topic that offer workarounds, but no…

External content

IcoMoon icons

Huge set of 315 free vector icons. You can choose which one you'd like, add your own SVGs, then download everything as an icon font or series of PNGs.

You can get up to 925 icons once you pay $59.

CSS: Vertically center with display: table-cell

Note: We have card with all CSS centering options. You probably want to head over there and get an overview over what techniques are available for your use case and browser requirements.


The classical scenario: There's a parent div element and you want to center some arbitrary child element vertically inside of it. Here's how you do it (also try this jsfiddle).

The children need to be block e…

Rubygems: Rebuild native extensions

Rarely, you might want to rebuild all gems with native extensions, because they might be compiled against outdated system libraries, resulting in some warnings or even segfaults or other ruby errors.

You can do that using

gem pristine --all

This will reset all gems to a pristine state as if you'd reinstall them, and as a side effect, rebuild all native extensions.

The above command will also help you sorting out errors like this after a distribution upgrade:

libmysqlclient_r.so.16: cannot open shared object file: No such fil...
External content

Subtle Patterns Preview

Ever wanted to preview a pattern from Subtle Patterns on your site without the hassle of swapping out images and modifying CSS?

Subtle Patterns Preview provides a simpler way to do it.

External content

Internet Explorer will download CSS files twice, if referenced via scheme-less URLs

You can use scheme-less URLs (or protocol-relative URLs) to have browsers use the current protocol (HTTP or HTTPS) when loading content referenced with such an URL.

A protocol relative URL doesn’t contain a protocol. For example, http://stevesouders.com/images/book-84x110.jpg becomes //stevesouders.com/images/book-84x110.jpg

Browsers substitute the protocol of the page itself for the resource’s missing protocol. Problem solved!

But:

Internet Explorer 7 & 8 will download st…

Cucumber: Wait for any requests to finish before moving on to the next scenario

Background

Generally, Selenium tests use the browser to interact with the page. If it's unavailable, a timeout error is thrown.

Now, consider a scenario like this:

@javascript
Scenario: Receive an e-mail after clicking the fancy link
  When I follow "fancy link"
  Then I should have an e-mail with the subject "Hello"

When the last step in the scenario passes, you are done. Right? Wrong.

Why it's not enough

What if clicking our "fancy link" above sends the e-mail that we expect, but it also does stuff on the server…

Regex pattern to validate email addresses

Our most recent pattern is

EMAIL = /\A[a-z0-9\+\-_\.]+@[a-z\d\-.]+\.[a-z]+\z/i

Notes

  • Don't replace [a-z0-9\+\-_\.] with \w ! Otherwise the pattern would allow ßs and many other invalid characters.
  • The email address standard allows more patterns of emails than those which work in practice (e.g. a@a is valid). In result our pattern is more strictly.
View
3280 cards