Skip to content

Instantly share code, notes, and snippets.

View timoschilling's full-sized avatar
👻
yolo

Timo Schilling timoschilling

👻
yolo
View GitHub Profile
class D
def macro
:referenced_in
end
def foreign_key
"listimage_asset_id"
end
def eager_load ids
#!/bin/sh
#
# Lives in .git/hooks.
# To enable this hook, rename this file to "pre-commit".
# Redirect output to stderr.
exec 1>&2
# works, but is slow. try with ack!
# LANG=C find . -name '*_spec.rb' | xargs egrep -q '^\s*(describe|it|context)\b.*focus'
@timoschilling
timoschilling / hlink.rb
Created April 8, 2013 13:54
ruby script to create recrosive hardlinks of files with directory structure
@timoschilling
timoschilling / mac.txt
Created April 17, 2013 15:50
set different mac address
sudo ifconfig en1 ether 60:33:4b:0b:50:0e
ifconfig en1 | grep ether
@timoschilling
timoschilling / client.sh
Created October 14, 2013 14:18
self made ical client/server ;)
telnet 127.0.0.1 1234
@timoschilling
timoschilling / rake
Last active August 26, 2015 14:27
demo simple rake
#!/usr/bin/env ruby
require "./rake_lib"
require "./test_task"
exec ARGV.first.to_sym
@timoschilling
timoschilling / twin.rb
Created September 10, 2015 09:20
Disposible::Twin.fake
class Disposable
class Twin
def self.fake
types = {}
representer_class.representable_attrs[:definitions].each_pair do |key, value|
types[key] = value.instance_variable_get(:@options)[:type]
end
attributes = {}
puts types
types.each_pair do |key, type|
@timoschilling
timoschilling / unsubscribe.rb
Created September 29, 2015 15:00
ActiveSupport::Notifications unsubscribe by regex
ActiveSupport::Subscriber.subscribers.flat_map(&:patterns).grep(/trailblazer/).map &ActiveSupport::Notifications.method(:unsubscribe)
@timoschilling
timoschilling / application_controller.rb
Created October 9, 2015 05:08
Trailblazer::WithCurrentUser maps you the current_user in your Trb params hash, this is just a idea and not save for work!
class ApplicationController < ActionController::Base
include Trailblazer::Operation::Controller
include Trailblazer::WithCurrentUser
self.trb_with_current_user_param_key = :current_user
self.trb_with_current_user_method = :current_user
end
@timoschilling
timoschilling / find_rails_url_helper_name.rb
Created October 21, 2015 14:35
find Rails url helper name
def find_route_name(path)
Rails.application.routes.routes.select do |route|
route.path.match path
end.map(&:name).compact.first
end