Skip to content

Instantly share code, notes, and snippets.

View floere's full-sized avatar
😁
Open Sourcing

Florian R. Hanke floere

😁
Open Sourcing
View GitHub Profile
# Just copy in TextMate and play
#
class Chain
def initialize lambdas
@lambdas = lambdas
end
# Wrapper.
#
def self.[] lam, *args
matrix = lambda { |x| lambda { |y| x*y**2 }}
p matrix[-3][-10] #=> -300
p matrix[0][0] #=> 0
p matrix[3][4] #=> 48
p matrix[10][20] #=> 4000
h = {:'->' => ->(x) {x}}
h[:'->']['->'] # => "->"
->(_){[200,{},'']}
# I have no idea why I wanted to write this down, honestly.
// I don’t care if
IOPIN0 & (1<<23);
// means anything to you. it doesn’t mean anything to me.
// So let’s move it to a method, which, when called, will
// make everything clear for everybody.
int isUSBConnected(void) {
return IOPIN0 & (1<<23);
# Run this with Ruby 1.9 and observe the output.
#
# Isn't it funky?
#
# Without shortcut
#
class Node
caller.each { |c| puts c };
# So Err the Blog really likes returning
# http://errtheblog.com/posts/27-quickly-returning
# (Ok, it's from 2006, but still ;) )
#
# I object to the first few examples (ask me why),
# but let's look at the code he shows:
#
def self.view_class
@view_class ||=
# create a new class based on the default template class
file = "0
77344 27830 77370 97392 105340 110573 92770 36971 61154 110351 18627 43803 53579
1
47830 104333 77340 111495 61839 13481 83523 54517 61154 5129 42438 53579 42863 57353 19410
2
101616 81738 104333 3405 116542 53579 61154 90523
3
106130 115219 84267 111281 111189 116345 29165 71557 64949 106506 53684 20517 60635 92770 9360 101739 68260 115414 27517 55659 96752 52707 49768 102654 85372 66616 40596 29630 93361 60685 31916 110351 113418 108253 111100 87893 105251 67611 61811 7445 42779 19164 108781 78473 33563 43560 64847 115800 27820 67173 70673 9559 33272 104702 57353 10441 26352 111937 42863 106279 10190 109520 29263 15704 109337 61289 26032 56865 90846 7697 96877 51925 54839 45292 116831 5129 18627 107024 77025 106736 49159 57507 80185 115062 113159 77340 117283 55784 117281 66415 111983 57368 41535 36971 101970 113717 80152 105338 31324 57109 62598 114444 40505 69792 26540 110573 104300 54517 9797 106086 8832 19833 41910 50048 43803 90748 79418 110757 104402 19290 11635 113080 16963 2997 98139 25519
# The following code can be used to reload a
# running application with updated code, for example
# in a unicorn process.
#
# In e.g. a file loader.rb
#
module Loader
def self.selfload