Skip to content

Instantly share code, notes, and snippets.

View leh's full-sized avatar

Daniel Lehmann leh

  • Taktsoft
  • Bonn / Germany
View GitHub Profile
# Offene Fragen
# - In diesem Szenario, wie wird hier sichergestellt, dass es nur genau ein tile image gibt?
# Theoretisch müsste portfolio_item.tile_image.first_or_create funktionieren?
# - Weiterhin nimmt dieses Szenario an, dass nur ein "Liste" von Source Images
# existiert, also die Uploads im eigene Portfolio und in der Detailansicht
# nicht unterschieden werden. Das müsste zuvor mit den Business-Leuten noch
# abgestimmt werden.
class PortfolioItem::Image < ActiveEceord::Base
extend Dragonfly::Model
@leh
leh / key_swapper.py
Created November 22, 2012 20:06
This python script allows you to change the unity/gnome keyboard settings for swapping the meta (windows) and alt keys. Should work with Python 2.7 and 3.2
#!/usr/bin/python
# This python script allows you to change the unity/gnome keyboard
# settings for swapping the meta (windows) and alt keys. Should work with
# Python 2.7 and 3.2
from gi.repository import Gio
class KeySwapper:
SWAP_ALT_WIN='altwin\taltwin:swap_lalt_lwin'
@leh
leh / restart_tmux
Created October 18, 2012 15:58
start or restore a tmux session named after your current working directory
# Switching projects like mad?
# t: start or restore a tmux session named after your current working directory
#
# e.g. calling t in /home/project/awesome_project will reattach the tmux session named
# awesome_project or create a new one
t() { tmux attach-session -t $(pwd | awk -F/ '{print $NF}') || tmux new-session -s $(pwd | awk -F/ '{print $NF}') ; }
@leh
leh / hyphen_test_de.rb
Created December 15, 2011 14:31
Hyphenate in Ruby
require 'minitest/autorun'
require 'text/hyphen'
describe Text::Hyphen do
let(:described_class) do
Text::Hyphen
end
it "should hyphenate vierschanzentourne correctly" do
hh = described_class.new(:language => 'de', :left => 2, :right => 2)
@leh
leh / whiny_attr_accessible.rb
Created September 1, 2011 08:58
Makes attr_accessible whiny. A monkey patch for Rails 3.1 to raise an exception instead of a warning in the logs when protected fields are mass assigned
# Rails edge includes pluggable sanitizers for mass assignment. Really cool is the
# StrictSanitizer which raises an exception instead of a log message, which makes
# problems easier to spot in development.
# For the time being, there seems to be no way to achieve this in Rails 3.1 via
# configuration. Monkey patching to the rescue!
# Copy the gist into config/initializers and configure the environments in which the
# exception gets raised.
if ['development', 'test'].include?(Rails.env)
ActiveModel::MassAssignmentSecurity::BlackList.class_eval do