Skip to content

Instantly share code, notes, and snippets.

View bakkdoor's full-sized avatar

Christopher Bertels bakkdoor

View GitHub Profile
@bakkdoor
bakkdoor / kvo.fy
Created January 25, 2012 01:35
Objective-C inspired Key-Value Observing in Fancy
class KVO {
class ClassMethods {
def define_slot_writer: slotname {
define_method: "#{slotname}:" with: |val| {
old_val = get_slot: slotname
set_slot: slotname value: val
match val {
case old_val -> nil # do nothing if no change
case _ ->
if: (__kvo_observers__[slotname to_sym]) then: @{ each: @{ call: [val] } }
#!/usr/bin/env fancy
# A simple guessing game written in Fancy.
amount-guesses = 6
"Welcone to the game!" println
random-number = 100 random + 1
amount-guesses downto: 1 do: |remaining-guesses| {
"You have #{remaining-guesses} guesses remaining." println
Rubinius Crash Report #rbxcrashreport
Error: signal �SIGSEGV
[[Backtrace]]
0 rbx 0x000000010b4d77c6 _ZN8rubiniusL12segv_handlerEi + 486�
1 libsystem_c.dylib 0x00007fff8ea54cfa _sigtramp + 26�
2 ??? 0x000000010dca32c0 0x0 + 4526322368�
3 rbx 0x000000010b699fec _ZN8rubinius13VariableScope4Info4markEPNS_6ObjectERNS_10ObjectMarkE + 124�
4 rbx 0x000000010b6b131b _ZN8rubinius16GarbageCollector11scan_objectEPNS_6ObjectE + 441�
Rubinius Crash Report #rbxcrashreport
Error: signal SIGSEGV
[[Backtrace]]
0 rbx 0x000000010b96e9c6 _ZN8rubiniusL12segv_handlerEi + 486
1 libsystem_c.dylib 0x00007fff8ea54cfa _sigtramp + 26
2 ??? 0x00007fa2059c63c0 0x0 + 140333855564736
3 libcrypto.0.9.8.dylib 0x00007fff8af503e4 CRYPTO_set_ex_data + 36
4 openssl.bundle 0x000000010f5f96dc ossl_x509store_set_vfy_cb + 60
@bakkdoor
bakkdoor / contracts.fy
Created November 12, 2011 15:18
Sample method with requirements on the argument. You can also define post conditions via ensure: { ... }
# usage:
class Fixnum {
def / other {
require: @{
other class is: Fixnum
other is > 0
} body: {
# actual method body goes here..
}
}
@bakkdoor
bakkdoor / sha1-error.txt
Created October 31, 2011 23:10
SHA1 error
$ rbx -e "require('sha1'); SHA1.new('foo')"
An exception occurred evaluating command line code
StackError (StackError)
Backtrace:
SHA1.orig_new (new) at projects/rubinius/lib/digest/sha1.rb:11
SHA1.orig_new (new) at projects/rubinius/lib/digest/sha1.rb:15 (7260 times)
SHA1.new at projects/rubinius/lib/sha1.rb:11
{ } in Object#__script__ at -e:1
Rubinius::BlockEnvironment#call_on_instance at kernel/common
@bakkdoor
bakkdoor / crashreport.txt
Created September 16, 2011 23:04
gdb rbx binfancy
Rubinius Crash Report #rbxcrashreport
Error: signal �SIGSEGV
[[Backtrace]]
[[System Info]]
sysname: Darwin
nodename: udp090078uds.ucsf.edu
release: 11.0.0
#!/Users/cb/projects/rubinius/bin/rbx
#
# This file was generated by RubyGems.
#
# The application 'fancy' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
@bakkdoor
bakkdoor / gist:1094462
Created July 20, 2011 06:38
compile error with fxruby
g++ -I. -I. -I/Users/backtype/projects/rubinius/vm/capi/include -I/Users/backtype/projects/idefy/FXRuby-1.6.19/ext/fox16 -DHAVE_SYS_TIME_H -DHAVE_SIGNAL_H -I/usr/local/include/fxscintilla -I/usr/local/include/fox-1.6 -fPIC -ggdb3 -O2 -fPIC -O0 -Iinclude -c FXRuby.cpp
FXRuby.cpp: In function ‘long int FXRbHandleMessage(FX::FXObject*, intptr_t, FX::FXObject*, FX::FXSelector, void*)’:
FXRuby.cpp:1271: error: invalid conversion from ‘intptr_t (*)()’ to ‘intptr_t (*)(...)’
FXRuby.cpp:1271: error: initializing argument 1 of ‘intptr_t rb_rescue2(intptr_t (*)(...), intptr_t, intptr_t (*)(...), intptr_t, ...)’
FXRuby.cpp:1271: error: invalid conversion from ‘intptr_t (*)()’ to ‘intptr_t (*)(...)’
FXRuby.cpp:1271: error: initializing argument 3 of ‘intptr_t rb_rescue2(intptr_t (*)(...), intptr_t, intptr_t (*)(...), intptr_t, ...)’
make: *** [FXRuby.o] Error 1
backtype ~/projects/fancy[master] $ rake -v
(in /Users/backtype/projects/fancy)
bison --output /Users/backtype/projects/fancy/lib/parser/ext/parser.c -d -v /Users/backtype/projects/fancy/lib/parser/ext/parser.y
/Users/backtype/projects/fancy/lib/parser/ext/parser.y:182.17-25: warning: type clash on default action: <object> != <>
/Users/backtype/projects/fancy/lib/parser/ext/parser.y: conflicts: 301 shift/reduce, 46 reduce/reduce
flex --outfile /Users/backtype/projects/fancy/lib/parser/ext/lexer.c --header-file=lexer.h /Users/backtype/projects/fancy/lib/parser/ext/lexer.lex
rbx /Users/backtype/projects/fancy/lib/parser/ext/extconf.rb
checking for main() in -lfl... yes
creating Makefile
flex --outfile /Users/backtype/projects/fancy/boot/rbx-compiler/parser/lexer.c --header-file=lexer.h /Users/backtype/projects/fancy/boot/rbx-compiler/parser/lexer.lex