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
CSV parsing | |
size parslet treetop csv | |
253: 0.020 0.020 0.000 | |
5293: 0.540 0.130 0.000 | |
10207: 1.170 0.210 0.000 | |
15247: 1.600 0.510 0.010 | |
20161: 2.430 0.650 0.010 | |
25201: 3.170 0.820 0.000 | |
30115: 3.970 0.970 0.210 | |
35155: 4.810 1.320 0.010 |
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
CSV parsing | |
size parslet treetop csv | |
253: 0.010 0.010 0.000 | |
5293: 0.330 0.120 0.010 | |
10207: 0.670 0.240 0.000 | |
15247: 1.100 0.430 0.000 | |
20161: 1.550 0.580 0.000 | |
25201: 1.950 0.810 0.010 | |
30115: 2.480 0.960 0.160 | |
35155: 3.100 1.130 0.010 |
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 'guard/guard' | |
module Guard | |
class UnicornHunter < Guard | |
# Called on file(s) modifications that the Guard watches. | |
# @param [Array<String>] paths the changes files or paths | |
# @raise [:task_has_failed] when run_on_change has failed | |
def run_on_change(paths) | |
if system("killall -m 'unicorn worker'") | |
puts "Unicorn hunter has found a unicorn..." |
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 'picky' | |
require 'facets' | |
require 'facets/array/combination.rb' | |
Picky.logger = Picky::Loggers::Silent.new | |
input = ARGV | |
Folder = Struct.new(:id, :name) | |
folders = Dir[ENV['HOME'] + "/**"]. |
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? } |
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 '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 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
#!/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
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? } |