Skip to content

Instantly share code, notes, and snippets.

View bakkdoor's full-sized avatar

Christopher Bertels bakkdoor

View GitHub Profile
@bakkdoor
bakkdoor / clap
Last active August 29, 2015 14:07
#!/usr/bin/env ruby
def 👏
print "👏 "
end
[ARGV[0].to_i, 1].max.times { 👏 }
puts

Keybase proof

I hereby claim:

  • I am bakkdoor on github.
  • I am bakkdoor (https://keybase.io/bakkdoor) on keybase.
  • I have a public key whose fingerprint is E6B0 B248 A05B E8DC A0F1 E13C FF17 6E5B 2345 B203

To claim this, I am signing this object:

diff --git a/lib/array.fy b/lib/array.fy
index a2a06f6..70fc565 100644
--- a/lib/array.fy
+++ b/lib/array.fy
@@ -7,6 +7,23 @@ class Array {
include: Fancy Enumerable
+ method_documentation: <[
+ 'at: => """
@bakkdoor
bakkdoor / fib.fy
Last active December 19, 2015 20:18
Fancy<->Ruby interop
class Integer {
def fib {
match self {
case @{ < 2 } -> self
case _ -> self - 1 fib + (self - 2 fib)
}
}
}
@bakkdoor
bakkdoor / while_else.fy
Created December 15, 2012 19:57
Sample implementation of while loop with additional else branch, if loop doesn't get executed (in Fancy).
class Object {
def while: condition do: body else: alternative {
if: (condition call) then: {
body call
while: condition do: body
} else: alternative
}
}
# usage:
require "rubygems"
require "celluloid"
class Ping
include Celluloid
def initialize(max)
@max = max
@count = @max
end
~/projects/fancy/dcell[master] $ rbx node1.rb
The Time is: Wed Feb 01 11:00:54 +0100 2012
D, [2012-02-01T11:00:59.694176 #56469] DEBUG -- : ZMQ error: got read event without associated reader
I, [2012-02-01T11:00:59.695723 #56469] INFO -- : Connected to node2
"0 hello world!"
"1 hello world!"
"2 hello world!"
"3 hello world!"
"4 hello world!"
"5 hello world!"
backtype ~/projects/fancy/dcell $ rbx node1.rb
An exception occurred running node1.rb
method 'new': given 7, expected 0 (ArgumentError)
Backtrace:
DCell.__module_init__ (DCell) at /Users/backtype/projects/ruby/rubinius
/gems/1.8/gems/dcell-0.8.0/lib/dcell
/rpc.rb:4
Object#__script__ at /Users/backtype/projects/ruby/rubinius
/gems/1.8/gems/dcell-0.8.0/lib/dcell
ERROR: the VM is exiting improperly running /Users/backtype/projects/fancy/fancy/bin/fancy
intended operation: :return
associated value: "tests/lib/active_riak/storage.fy" # <- this String changes most of the time, it's the file that's being require:'d (see return (raise_return) @ https://github.com/bakkdoor/fancy/blob/master/lib/rbx/code_loader.fy#L52)
destination scope:
method: find_file: at lib/rbx/code_loader.fy:50
module:
@bakkdoor
bakkdoor / chain.fy
Created January 25, 2012 12:09
chained #map: in Fancy (see https://gist.github.com/1675672)
class Fancy Enumerable {
def map_chained: blocks {
map: @{
map: |v| {
blocks inject: v into: |acc b| {
b call: [acc]
}
}
}
}