Skip to content

Instantly share code, notes, and snippets.

View bakkdoor's full-sized avatar

Christopher Bertels bakkdoor

View GitHub Profile
require "rubygems"
require "xmpp4r"
jid = Jabber::JID.new "[email protected]"
client = Jabber::Client.new jid
client.connect
puts "connected!"
client.auth "mysecretpassword"
puts "authenticated!"
client.close
backtype ~/Downloads $ rbx ffi-cairo.rb
An exception occurred running ffi-cairo.rb
Tried to use non-reference value 0x1 as type Float (25) (TypeError)
Backtrace:
Object#__script__ at ffi-cairo.rb:263
Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:65
Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:90
Rubinius::Loader#script at kernel/loader.rb:591
Rubinius::Loader#main at kernel/loader.rb:721
def while: a do: b {
loop() {
a call if_true: b else: { return nil }
}
}
i = 0
while: { i < 1_000_000 } do: {
i println
i = i + 1
@bakkdoor
bakkdoor / methods.diff
Created May 4, 2011 07:57
false/nil/true -> methods
diff --git a/lib/compiler/ast/identifier.fy b/lib/compiler/ast/identifier.fy
index 591036b..49e70fa 100644
--- a/lib/compiler/ast/identifier.fy
+++ b/lib/compiler/ast/identifier.fy
@@ -53,9 +53,9 @@ class Fancy AST {
def bytecode: g {
pos(g)
match @string {
- case "true" -> g push_true()
- case "false" -> g push_false()
require("rubygems")
require("sinatra")
get("/") {
"Hello, Sinatra, from Fancy!"
}
Sinatra Application run!()
require("rubygems")
require("sinatra")
gives me:
An exception occurred running /Users/backtype/projects/fancy/bin/fancy
invalid identifier if_nil: (NameError)
Backtrace:
{ } in Object#DelegateClass at /Users/backtype/projects/rubinius/lib
backtype ~/projects/rubinius[master] $ rbx
irb(main):001:0> require "rubygems"
=> true
irb(main):002:0> require "fancy"
=> true
irb(main):004:0> r = Range.fy :new, 0, :to, 100
=> 0..100
irb(main):005:0> r.fy :each, Proc.new{|i| i.fy :println}
0
1
@bakkdoor
bakkdoor / fiber.fy
Created March 7, 2011 01:42
Running fiber.fy in fancy (with JIT on)
# define some additional methods
class Fiber {
def sleep: seconds {
@sleep_end = Time now + seconds
}
def asleep? {
if: @sleep_end then: {
Time now < @sleep_end
}
def meth: block {
block call: [1,2]
}
meth: |a,b| {
# do stuff here with a and b
}
---------------------------------------------
CRASH: A fatal error has occured.
Backtrace:
0 rbx 0x00000001000201f0 _ZN8rubiniusL12segv_handlerEi + 160
1 libSystem.B.dylib 0x00007fff86a4567a _sigtramp + 26
2 ??? 0x0000003236346461 0x0 + 215657768033
3 rbx 0x0000000100208b82 _ZN8rubinius17VisitInstructionsINS_8JITVisitEE8dispatchEi + 4962
4 rbx 0x00000001001e9af4 _ZN8rubinius3jit7Builder13generate_bodyEv + 1156
5 rbx 0x00000001001d2159 _ZN8rubinius7Inliner21inline_generic_methodEPNS_5ClassEPNS_6ModuleEPNS_14CompiledMethodEPNS_8VMMethodE + 1545