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
#![deny(warnings)] | |
extern crate futures; | |
extern crate hyper; | |
extern crate pretty_env_logger; | |
extern crate serde_json; | |
use futures::{future, Future}; | |
use hyper::{Body, Client, Request, Response, Server}; | |
use hyper::client::HttpConnector; |
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
class Foo | |
def to_s | |
1 | |
end | |
# Just to make sure ;) | |
def inspect | |
'a foo' | |
end | |
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 'rspec' | |
require 'dm-transactions' | |
RSpec.configure do |rspec| | |
rspec.mock_with :flexmock | |
end | |
describe 'transaction block behaviour' do | |
let(:t) { DataMapper::Transaction.new() } |
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
diff --git a/lib/rip/compiler/parser.rb b/lib/rip/compiler/parser.rb | |
index eb60b43..2416e3d 100644 | |
--- a/lib/rip/compiler/parser.rb | |
+++ b/lib/rip/compiler/parser.rb | |
@@ -261,11 +261,13 @@ module Rip::Compiler | |
rule(:heredoc_start) { angled_open.repeat(2, 2) >> heredoc_label >> line_break } | |
rule(:heredoc_label) { match['A-Z_'].repeat(1).capture(:heredoc_label) } | |
- rule(:heredoc_content) { (heredoc_end.absent? >> heredoc_content_any >> (line_break.absent? >> heredoc_content_any).repeat >> heredoc_content_any).repeat(1) } | |
+ # rule(:heredoc_content) { (heredoc_end.absent? >> heredoc_content_any >> (line_break.absent? >> heredoc_content_any).repeat >> heredoc_content_any).repeat(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 'strscan' | |
# Inspired by | |
# http://eli.thegreenplace.net/2012/08/02/parsing-expressions-by-precedence-climbing/ | |
# A succinct implementation of precedence climbing in Ruby | |
operations = {} | |
%w(+ -).each { |c| operations[c] = [:left, 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
class Foo | |
def respond_to?(sym) | |
if sym == :foo | |
return true | |
else | |
super | |
end | |
end | |
end | |
class Bar |
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
# Encoding: UTF-8 | |
require 'fiber' | |
HEADER = 0x61 | |
FOOTER = 0x62 | |
DLE = 0xAB | |
def after_dle(x) | |
x |
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' | |
include Parslet | |
input = %w(a aa b) | |
class El < Parslet::Atoms::Base | |
def initialize(pattern) | |
@pattern = pattern | |
super() | |
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
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 |
NewerOlder