This file contains hidden or 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
task :ring_alarm do | |
puts "RIIIIIIING" | |
end | |
task :wake_up => :ring_alarm do | |
puts "Whwhoooooaaa what a nice day! Just woke up!" | |
end | |
task :dress_up => :wake_up do | |
puts "Yeah, I'm dressing up" |
This file contains hidden or 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 Lani::Parser | |
macro | |
# our macros go here | |
rule | |
# our rules go here | |
inner | |
# here we put any ruby code we want to extend our lexer with. | |
# for example, our own tokenize method. | |
def tokenize(code) | |
scan_setup(code) |
This file contains hidden or 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
foo = lambda do |a, b=a.upcase| | |
b | |
end | |
p foo["hey"] # => "HEY" |
This file contains hidden or 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
comp = (fns...) -> | |
(arg) -> | |
fns.reverse().reduce((x, fn) -> | |
fn(x) | |
, arg) | |
timesthree = (a) -> a * 3 | |
timestwo = (a) -> a * 2 | |
negative = (a) -> -a |
This file contains hidden or 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
while true | |
value = rand > 0.8 ? "\e[031mF\e[0m" : "\e[032m.\e[0m" | |
print value | |
sleep rand / 2 | |
end |
This file contains hidden or 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
def write_backtrace name, backtrace, filename | |
exceptions = Regexp.union([ | |
/\.bundle/, | |
/spec/, | |
/test/, | |
/lib\/ruby\/1.9.1/ | |
]) | |
backtrace.reject! { |line| line =~ exceptions } |
This file contains hidden or 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
# app.rb | |
# | |
# Usage: | |
# | |
# $ gem install sinatra | |
# $ ruby app.rb | |
# | |
require 'sinatra' | |
get '/' do |
This file contains hidden or 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
import Data.List (intersperse) | |
tuplify3 :: [a] -> (a,a,a) | |
tuplify3 [x,y,z] = (x,y,z) | |
violations :: String -> [(String, String, String)] | |
violations = (map tuplify3) . (map words) . lines | |
methodName :: (String, String, String) -> String | |
methodName (_, x, _) = x |
This file contains hidden or 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
curried_add = -> a, b, c { a + b + c }.curry | |
add3 = curried_add[3] | |
add3and4 = add3[4] | |
add3and4[10] # => 17 |
This file contains hidden or 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
Rubinius Crash Report #rbxcrashreport | |
Error: signal SIGSEGV | |
[[Backtrace]] | |
0 ruby 0x0000000105c82650 _ZN8rubiniusL12segv_handlerEi + 544 | |
1 libsystem_c.dylib 0x00007fff8b72994a _sigtramp + 26 | |
2 ??? 0x00007f9ae211db70 0x0 + 140303194512240 | |
3 profiler_vm.bundle 0x000000010a750c71 _ZN8profiler12_GLOBAL__N_117tool_enter_methodEPN5rbxti3EnvEPNS1_14InternalObjectEPNS1_14InternalSymbolEPNS1_14InternalModuleEPNS1_20InternalCompiledCodeE + 257 | |
4 ruby 0x0000000105cf4370 _ZN8rubinius11MachineCode19execute_specializedINS_11OneArgumentEEEPNS_6ObjectEPNS_5StateEPNS_9CallFrameEPNS_10ExecutableEPNS_6ModuleERNS_9ArgumentsE + 1024 |