This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'ruby_parser' | |
class Graph | |
def initialize | |
@watch_lvars = [] | |
end | |
def visit(tree) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Matcher | |
def initialize(expr) | |
@expr = expr | |
end | |
def ===(value) | |
@bindings = {} | |
match(@expr, value, @bindings) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
require 'parslet' | |
require 'parslet/convenience' | |
class MiniP < Parslet::Parser | |
# Single character rules | |
rule(:lparen) { str('(') >> space? } | |
rule(:rparen) { str(')') >> space? } | |
rule(:comma) { str(',') >> space? } |
OlderNewer