Skip to content

Instantly share code, notes, and snippets.

View kschiess's full-sized avatar
💭
see .plan

Kaspar Schiess kschiess

💭
see .plan
View GitHub Profile
@kschiess
kschiess / keybase.md
Created September 23, 2014 07:17
Keybase authentication.

Keybase proof

I hereby claim:

  • I am kschiess on github.
  • I am kschiess (https://keybase.io/kschiess) on keybase.
  • I have a public key whose fingerprint is 410C D966 C2FE D140 1ADA 77E9 8C67 10A3 D7A0 791E

To claim this, I am signing this object:

@kschiess
kschiess / symbol_hash_to_a.rb
Created May 3, 2010 06:50 — forked from floere/symbol_hash_to_a.rb
Exploration on to_proc and each
# Its easy really, you want the proc to 'plus' to arguments really, so
# just put a plus in there!
# (Or: Most flagrant abuse of unary plus)
class AsArgument < Struct.new(:symbol)
def to_proc
proc { |el| send(symbol, el) }
end
end
class Symbol
@kschiess
kschiess / coldir.rb
Created December 10, 2010 15:24
Gathers key information about a directory.
#!/opt/csw/bin/ruby
directory = ARGV.join(' ')
count = ['?', '?']
# get users, which have created files in dir
#
users = Hash.new(0)
`tree -u '#{directory}'`.split("\n").each do |line|
@kschiess
kschiess / gist:757123
Created December 28, 2010 10:31
a patch for the map gem
From 76d3b0e6e95097915e210faccc226562fe2723de Mon Sep 17 00:00:00 2001
From: Kaspar Schiess <kaspar.schiess@absurd.li>
Date: Tue, 28 Dec 2010 11:24:04 +0100
Subject: [PATCH 1/2] . ignores argument and is thus a proc
---
lib/map.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
@kschiess
kschiess / gist:772799
Created January 10, 2011 14:02
A minimal filtered rspec run (and a quine)
# puts (s="puts (s=%s)%%s.dump")%s.dump
require 'rspec'
RSpec::Core::Runner.disable_autorun!
describe "foo" do
it "bar" do
end
it "baz", :banane => true do
end
require 'rubygems'
require 'parslet'
require 'pp'
class JSON < Parslet::Parser
rule(:space) { match('\s').repeat(1) }
rule(:space?) { space.maybe }
rule(:quote) { str('"') }
rule(:nonquote) { str('"').absnt? >> any }
rule(:comma) { str(',') >> space? }
@kschiess
kschiess / split.rb
Created February 15, 2011 10:40
prints instance variable accesses inside a class methods.
#!/usr/bin/env ruby
require 'ruby_parser'
class Graph
def initialize
@watch_lvars = []
end
def visit(tree)
@kschiess
kschiess / gist:1151562
Created August 17, 2011 13:51
A matcher thingy.
class Matcher
def initialize(expr)
@expr = expr
end
def ===(value)
@bindings = {}
match(@expr, value, @bindings)
end
require 'parslet'
require 'parslet/convenience'
require 'pp'
def parse(input)
parser = SongParser.new
begin
tree = parser.parse(input)
rescue Parslet::ParseFailed => error
puts error, parser.root.error_tree
@kschiess
kschiess / prevent.rb
Created October 26, 2011 11:48
How to prevent rake from polluting global namespace
class Module
def with_rake_pollution_prevention_append_features(klass)
unless caller.first.match(/rake/) && self.name == "Rake::DeprecatedObjectDSL"
without_rake_pollution_prevention_append_features(klass)
end
end
alias without_rake_pollution_prevention_append_features append_features
alias append_features with_rake_pollution_prevention_append_features
end