Skip to content

Instantly share code, notes, and snippets.

BEG_REGEXP = /\G(?:\
(?# 1: SPACE )( +)|\
(?# 2: NIL )(NIL)(?=[\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+])|\
(?# 3: NUMBER )(\d+)(?=[\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+])|\
(?# 4: ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+]+)|\
(?# 5: QUOTED )"((?:[^\x00\r\n"\\]|\\["\\])*)"|\
(?# 6: LPAR )(\()|\
(?# 7: RPAR )(\))|\
(?# 8: BSLASH )(\\)|\
(?# 9: STAR )(\*)|\

Keybase proof

I hereby claim:

  • I am Benny1992 on github.
  • I am Benny1992 (https://keybase.io/Benny1992) on keybase.
  • I have a public key whose fingerprint is E126 3CBE CA1B 3E42 5A91 F161 C5E1 8BD6 0B92 E82E

To claim this, I am signing this object:

There are several built-in machines available for use. They are all two state machines for the purpose of matching common classes of characters. They are:
– any – Any character in the alphabet.
– ascii – Ascii characters. 0..127
– extend – Ascii extended characters. This is the range -128..127 for signed alphabets and the range 0..255 for unsigned alphabets.
– alpha – Alphabetic characters. [A-Za-z]
– digit – Digits. [0-9]
– alnum – Alpha numerics. [0-9A-Za-z]
– lower – Lowercase characters. [a-z]
– upper – Uppercase characters. [A-Z]
@tak1n
tak1n / report1.rb
Last active August 29, 2015 14:01
Report method with io.sync = self.old_sync
def report # :nodoc:
super
io.puts "before sync"
io.sync = self.old_sync
io.puts "after sync"
io.puts unless options[:verbose] # finish the dots
io.puts
io.puts statistics
@tak1n
tak1n / report2.rb
Last active August 29, 2015 14:01
Report method without io.sync = self.old_sync
def report # :nodoc:
super
io.puts "before sync"
# io.sync = self.old_sync
io.puts "after sync"
io.puts unless options[:verbose] # finish the dots
io.puts
io.puts statistics
Tokenized input:
[[:T_KEYWORD_DEF, "->"], [:T_LITERAL, "ohai"], [:T_LBR, "("], [:T_LITERAL, "a"], [:T_COL, ","], [:T_LITERAL, "b"], [:T_COL, ","], [:T_LITERAL, "d"], [:T_COL, ","], [:T_LITERAL, "e"], [:T_RBR, ")"], [:T_LITERAL, "c"], [:T_EQ, "="], [:T_LITERAL, "a"], [:T_MUL, "*"], [:T_LITERAL, "b"], [:T_LITERAL, "f"], [:T_EQ, "="], [:T_LITERAL, "c"], [:T_ADD, "+"], [:T_LITERAL, "d"], [:T_MUL, "*"], [:T_LITERAL, "e"], [:T_KEYWORD_OUT, "puts"], [:T_LITERAL, "c"], [:T_KEYWORD_END, "<-"], [:T_LITERAL, "ohai"], [:T_LBR, "("], [:T_INT, 3], [:T_COL, ","], [:T_INT, 5], [:T_COL, ","], [:T_INT, 8], [:T_COL, ","], [:T_INT, 9], [:T_RBR, ")"]]
Abstract Syntax Tree:
[:block, [:stmt, [:defn, "ohai", [:arglist, [:literal, :a], [:literal, :b], [:literal, :d], [:literal, :e]], [:block, [:stmt, [:equal, [:literal, :c], [:op, [:mul, [:literal, :a], [:literal, :b]]]], [:equal, [:literal, :f], [:op, [:mul, [:op, [:add, [:literal, :c], [:literal, :d]]], [:literal, :e]]]], [:stdout, [:literal, :c]]]]], [:call, "ohai", [:arglist, [:
@tak1n
tak1n / Timings
Created June 5, 2014 08:45
Ruby Fibonacci "Benchmark"
Ruby HEAD - 7,36s user 0,02s system 99% cpu 7,390 total
Ruby 2.1.2 - 7,09s user 0,02s system 99% cpu 7,122 total
Ruby 2.1.1 - 7,02s user 0,01s system 99% cpu 7,049 total
Ruby 2.0.0 - 7,43s user 0,02s system 99% cpu 7,470 total
Ruby 1.9.3 - 10,75s user 0,02s system 99% cpu 10,787 total
Rubinius 2.2.7 - 2,50s user 0,05s system 106% cpu 2,388 total
Jruby 1.7.12 - 7,95s user 0,16s system 156% cpu 5,177 total
@tak1n
tak1n / test_helper_part.rb
Created June 25, 2014 22:07
When testing with capybara
# Make all database transactions use the same thread
# This is needed so tests wich uses webkit (javascript enabled feature testing) also use the same thread for database transactions
# Furthermore this is needed so db changes made in these feature tests are able to be rolled back
ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do
def current_connection_id
Thread.main.object_id
end
end
@tak1n
tak1n / rubinius_privately.rb
Created June 29, 2014 18:31
Rubinius Privatley
class User
def initialize(name)
@name = name
end
protected
def hash
@name.hash
end
end
cargo (master) $ rustc -v rbx
rustc 0.11.0-nightly (b57d272e9908e164a72bd1a688141031705e1208 2014-07-11 01:11:36 +0000)
cargo (master) $ git pull origin master rbx
From github.com:rust-lang/cargo
* branch master -> FETCH_HEAD
Already up-to-date.
cargo (master) $ make rbx
mkdir -p target