Skip to content

Instantly share code, notes, and snippets.

View munkius's full-sized avatar

Sander Nieuwenhuizen munkius

  • Amsterdam
View GitHub Profile
#!/bin/sh
# Welcome to the TMI laptop script!
# Inspired by and adapted from https://raw.githubusercontent.com/thoughtbot/laptop/master/mac
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\\n$fmt\\n" "$@"
@munkius
munkius / README.md
Last active March 25, 2016 23:46 — forked from rowanu/README.md
The Hotness Dashing widget updated for inversed ranges

Dashing Hotness Widget

Are you dashing? Are you hot? Then you need the Dashing Hotness Widget!

See the blog post for more details.

About

This widget is similar to the basic Number widget, except that the entire widget changes colour based on the value displayed. It is designed to draw attention to

@munkius
munkius / path_helper.rb
Created October 27, 2013 19:06
This Rails module takes locales into account when rendering a link to the current path. It takes into consideration all parameters. This is useful when you want a user to be able to switch languages and you want the user to stay on the same URL. When passing the default locale, it will be stripped off. For other details, take a look at the spec.
module PathHelper
class LocaleUtil
def delocalize_url(url)
result = url.sub(/^\/(?:#{locales_in_correct_order.join('|')})/, '')
[result, '/'].reject(&:blank?).first
end
def locales_in_correct_order
I18n.available_locales.map(&:to_s).sort_by(&:length).reverse