Skip to content

Instantly share code, notes, and snippets.

View hmans's full-sized avatar
🚀
Let's go!

Hendrik Mans hmans

🚀
Let's go!
View GitHub Profile
class ResourceController < ApplicationController
helper_method :resource, :collection
before_filter do
params[resource_name.to_sym] &&= resource_params
end
def index(&blk)
respond_with *(resource_parents + [collection]), &blk
end
# create a /backups directory
mkdir /backups
# tar everything except system directories (and the backups directory itself)
tar -cvpf /backups/fullbackup.tar --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups .
@hmans
hmans / gist:4492893
Last active October 7, 2016 13:54
A common environment variable for Ruby version switchers?

bash-it and ohmyzsh are two popular frameworks for extending the functionality of Bash and ZSH, respectively. One of their features is a built-in themeing system, and both implementations already try to integrate with some (but not all) Ruby version switchers to display the currently active Ruby as part of the shell prompt. At least in bash-it's case, this integration appears to have started out supporting RVM only, with support for rbenv and rbfu added later. This results in unfortunate code like this example.

We've recently agreed to use .ruby-version instead of switcher-specific files (.rbfu-version, .rbenv-version etc.), maybe we can also find a simple common name for an environment variable containing the currently selected Ruby (including patchlevel)?

Right now, the two alternatives I'm seeing are:

  1. Implementing switcher-specif
@hmans
hmans / gist:4251339
Created December 10, 2012 15:45
Why I don't like Slim

Confusing syntax

The following are equivalent:

h1 Lorem
   Ipsum

h1 
 | Lorem
@hmans
hmans / Gemfile
Created September 20, 2012 15:00
My Gemfile
source 'https://rubygems.org'
# Bundler 1.2.0 allows for specifying the required Ruby version in the Gemfile,
# so let's do that here.
ruby '1.9.3'
# Rails, obviously.
gem 'rails', '3.2.8'
# I love HAML.
@hmans
hmans / gist:3313741
Created August 10, 2012 11:46
Facebook signed_request + Rails (with Koala)
class ApplicationController < ActionController::Base
protect_from_forgery
def fb_liked?
session[:signed_request]['page']['liked'] if session[:signed_request]
end
def fb_admin?
session[:signed_request]['page']['admin'] if session[:signed_request]
end
@hmans
hmans / cheesecake.md
Last active April 28, 2020 20:56
Motherfucking Cheesecake

MOTHERFUCKING CHEESECAKE

Zutaten:

Für den Boden:

  • 150g Vollkornbutterkekse
  • 2 EL Zucker
  • Prise Zimt
  • 60g weiche Butter
@hmans
hmans / speaker.md
Created June 30, 2012 10:23 — forked from matiaskorhonen/speaker.md
Frozen Rails Talk Proposal Template (http://2012.frozenrails.eu/)
@hmans
hmans / gist:2996065
Created June 26, 2012 14:22
How to use Compass outside Rails or Sinatra (eg., in pure Rack apps or frameworks like Happy)
# Require the compass gem. No need to do this if you're already requiring all your
# gems through Bundle.require.
#
require 'compass'
# This adds the stylesheets directory of the "compass" engine to Sass' default load path. The
# only other engine in Compass at the time of writing is "blueprint", which, as far as I
# know, is already tagged as deprecated.
#
Sass::Engine::DEFAULT_OPTIONS[:load_paths] << Compass::Frameworks["compass"].stylesheets_directory
@hmans
hmans / gist:2891302
Created June 7, 2012 20:16
Happy for the curious.
# install happy-cli prerelease (!) gem
gem install happy-cli --pre
# create a new happy app using the standard app template
happy new myapp
# alternatively, use the minimal template
happy new myapp -t minimal
# then: