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
$:.unshift 'PATHTOINTERNALSCODE' | |
require 'string_internals.bundle' | |
def scan_for title, s, indent=0 | |
GC.start | |
times = 0 | |
content = '' | |
ObjectSpace.each_object(String) do |str| | |
if str == s | |
times += 1 |
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
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
# 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 |