Skip to content

Instantly share code, notes, and snippets.

Hendrik Mans hmans

View GitHub Profile
hmans / Disabling Rails generators you don't
Last active Oct 11, 2016
Disable some Rails generators you don't need to run all the time
View Disabling Rails generators you don't

Disable some Rails generators you don't need to run all the time

Reasoning: the Rails default is to generate a separate .coffee (or .js) and .scss file for each controller you add to your application. This may not be what you need. Adding the following lines to your development environment's configuration file will prevent this from happening:

# In config/environments/development.rb
config.generators.stylesheets = false
config.generators.javascripts = false
config.generators.helper      = false
View fizzbuzz.ex
defmodule FizzerBuzzer do
def go do
def go(num) when num == 101 do
def go(num) do
cond do
hmans / gist:cd5e2e989ceff7ff163a
Last active Aug 29, 2015
Ruby Configuration Thingy
View gist:cd5e2e989ceff7ff163a
class ConfigurationProxy
attr_reader :data
def initialize
@data = {}
def method_missing(method, *args, &blk)
if args.any? || block_given?
if block_given?
hmans / gist:cf18d182c51fb9191df6
Created Jun 29, 2014
PostgreSQL Large Object Data Store for Dragonfly
View gist:cf18d182c51fb9191df6
# This is a Dragonfly data store using PostgreSQL Large Objects. It appears to work fine,
# but I ended up using a different solution in my project. Anyway, here you go.
class PostgresDataStore
def write(content, opts={})
data_oid = store_lo(
meta_oid = store_lo(Marshal.dump(content.meta))
View EndlessSpace.cs
using UnityEngine;
using System.Collections;
public class EndlessSpace : MonoBehaviour {
public GameObject tile;
public GameObject player;
private float width, height;
private Vector3 offset, up, right, down, left;
hmans / application.html.slim
Last active Dec 14, 2018
Application layout for Rails (4 and 5), Slim style.
View application.html.slim
doctype html
title My App
meta name="viewport" content="width=device-width, initial-scale=1.0"
= stylesheet_link_tag "application", media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag "application", 'data-turbolinks-track' => true
= csrf_meta_tags
hmans / gmail.css
Created Oct 2, 2013
A user stylesheet for Google Mail that hopefully makes the whole thing slightly less terrible.
View gmail.css
/* This is a simple user stylesheet for the current version of Google Mail.
I think it makes Gmail's design slightly less terrible. Use it with your
favorite user stylesheet plugin or the excellent MailPlane client.
-- Hendrik Mans <> */
/* Mails */
tr.zA {
height: 1.65em;
hmans /
Created Aug 29, 2013
Cheesecake! \o/


Für eine handelsübliche ~26cm-Springform.

Für den Boden:

  • ~175g Vollkornbutterkekse, fein zerböselt
  • 2 EL Zucker
  • Prise Zimt
  • 60g geschmolzene Butter
hmans / application_controller.rb
Created Jul 24, 2013
Make CanCan 1.6 work with Rails 4 (or Rails 3 with StrongParameters)
View application_controller.rb
class ApplicationController < ActionController::Base
# ...
# Workaround for CanCan vs. SecureParameters.
# Invokes #secure_params and merges the returned hash back into #params.
prepend_before_filter only: [:create, :update] do
secure_params.each do |k, v|
params[k] &&= v
View resource_controller.rb
class ResourceController < ApplicationController
helper_method :resource, :collection
before_filter do
params[resource_name.to_sym] &&= resource_params
def index(&blk)
respond_with *(resource_parents + [collection]), &blk
You can’t perform that action at this time.