Skip to content

Instantly share code, notes, and snippets.

@judofyr
judofyr / fizzbuzz.rb
Created August 1, 2012 21:37 — forked from JEG2/fizzbuzz.rb
Writing FizzBuzz with flip-flops
a=b=c=(1..100).each do |num|
print num, ?\r,
("Fizz" unless (a = !a) .. (a = !a)),
("Buzz" unless (b = !b) ... !((c = !c) .. (c = !c))),
?\n
end
@judofyr
judofyr / fun.rb
Created August 1, 2012 14:25 — forked from andkerosine/fun.rb
class Symbol
def | other
-> arg { other.to_proc[arg.send(self)] }
end
def call(*args)
-> arg { arg.send(self, *args) }
end
end
@judofyr
judofyr / books.txt
Created July 1, 2012 13:55
Currently on my reading list
Some free books from Amazon, some blog posts, some textbooks, some poetry.
Wool
Howey, Hugh
Liars and Outliers: Enabling the Trust that Society Needs to Thrive
Schneier, Bruce
Brainstorming Doesn’t Really Work : The New Yorker
@judofyr
judofyr / display.dasm
Created April 12, 2012 13:05
more assembly from 0x10c leak
; Printing stuff to the screen
; by Markus Persson
#macro clear(color) {
push(a)
set a, color
shl a, 8
bor a, 0x20
mem_fill(0x8000, 0x180, a)
set [screen_p], 0
@judofyr
judofyr / dcpu-assembler.rb
Created April 4, 2012 15:32
Assembler for DCPU-16
class Register < Struct.new(:name)
BASIC = %w[A B C X Y Z I J].map(&:to_sym)
SPECIAL = %w[POP PEEK PUSH SP PC O].map(&:to_sym)
ALL = BASIC + SPECIAL
attr_accessor :plus
def value
case name
when *BASIC
@judofyr
judofyr / approve.rb
Created April 3, 2012 15:19
prove meets Ruby
# Place this in test/
#
# Run your tests with:
#
# prove -e 'ruby -Ilib:test' -v t/*.rb
#
# See the bottom for usage.
require 'minitest/unit'
@judofyr
judofyr / evil.rb
Created March 29, 2012 15:21
Experimenting with MRI internals in FFI
require 'ffi'
class Object
def memory_location
object_id * 2
end
def to_pointer
FFI::Pointer.new(memory_location)
end
@judofyr
judofyr / perlbrew.diff
Created February 3, 2012 11:39
Perlbrew for Travis
diff --git a/ci_environment/perlbrew/attributes/default.rb b/ci_environment/perlbrew/attributes/default.rb
new file mode 100644
index 0000000..e69de29
diff --git a/ci_environment/perlbrew/attributes/multi.rb b/ci_environment/perlbrew/attributes/multi.rb
new file mode 100644
index 0000000..2c9dad4
--- /dev/null
+++ b/ci_environment/perlbrew/attributes/multi.rb
@@ -0,0 +1,5 @@
+default[:perlbrew][:notests] = true
@judofyr
judofyr / broken.js
Created December 9, 2011 22:13
Broken `buster static`
// app.js
NoBug = true;
// test/bug-test.js
buster.testCase('Buster', {
'should not be buggy': function() {
assert(NoBug);
}
});
class Parser
def force; self end
def |(other)
DisjunctiveParser.new(self, other)
end
def >>(other)
SequentialParser.new(self, other)
end