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
h = {:'->' => ->(x) {x}}
h[:'->']['->'] # => "->"
class A
def self.inherited inheriter
class << inheriter
def inherited inheriter
Object.const_set inheriter.name.to_sym, self
p "Sorry, A can't have grandchildren. You, #{inheriter}, are instead to be of class #{self}."
end
end
end
end
; lisp
(defmacro x-injector ()
'x)
->(_){[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);
// Say, you want only to use the latest arriving ajax request.
// For example in a search engine, where only the request of the
// most recently sent request is of interest. Responses that come
// after and have been sent before the one that has already arrived
// are ignored:
// remember the latest request date
//
var latestRequestDate = new Date();
function responseHandler() {
# In your unicorn.rb
#
after_fork do |server, worker|
GC.disable
end
# The rack app.
#
Responder = lambda do |env|
harakiri
class Array
# Note: Could also be called ary_join.
#
def real_join element
combined = [element]*(size-1)
zip(combined).flatten.compact
end
end
p [1,2,3,4].real_join 'and' #=> [1, 'and', 2, 'and', 3, 'and', 4]
# 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