Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<html>
<head>
<title>list.c</title>
<style type="text/css">
body { color:#000000; background-color:#ffffff }
body { font-family:Helvetica, sans-serif; font-size:10pt }
h1 { font-size:14pt }
.code { border-collapse:collapse; width:100%; }
.code { font-family: "Monospace", monospace; font-size:10pt }
@JoergWMittag
JoergWMittag / DemonstrateMutableVsImmutable.java
Created March 22, 2014 03:17
Demonstrate the difference between mutating a value and reassigning a different value.
class MutableInt {
private int value;
MutableInt(int value) {
this.value = value;
}
void mutate() {
value++;
}
@JoergWMittag
JoergWMittag / open_classes.py
Created April 26, 2012 11:46
Python does have open classes
class A(object):
def p(__self__):
print("1")
a = A()
a.p()
def p2(__self__):
print("2")
;; This is the Ioke code for comparison.
;; See <http://JoergWMittag.GitHub.Com/lambdaconscarcdr/> for
;; what this is supposed to do.
cons = fn(hd, tl, fn(x, if(x, hd, tl)))
car = fn(l, l(true ))
cdr = fn(l, l(false))
l = cons(1, cons(2, nil))
# We want a uniform way of reducing a code tree
# so the easiest way to do that is to extend
# Object with a call method and whenever any
# object does not define it's own call method we
# assume the object is implicitly claiming it wants
# to return itself. Since Object is almost at the top
# of the hierarchy almost anything we are interested
# in will work as expected.
class Object
def call
require 'rack'
class Object
def webapp
tap {
def self.call(env)
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
}
@JoergWMittag
JoergWMittag / yelp_sample_response.json
Created June 10, 2010 16:43
Sample response for the Yelp search API
{"businesses":[
{"address1":"466 Haight St",
"city":"San Francisco",
"mobile_url":"http://mobile.yelp.com/biz/yyqwqfgn1ZmbQYNbl7s5sQ",
"name":"Nickies",
"address2":"",
"avg_rating":4,
"latitude":37.772201,
"zip":"94117",
"address3":"",
@JoergWMittag
JoergWMittag / reia_familytree.graphviz
Created May 25, 2009 12:11
The Family Tree of the Reia Programming Language
digraph Reia {
Planner -> Prolog [label="Logic Programming"];
Planner -> Actors [label="Carl Hewitt"];
Prolog -> Erlang [label="Syntax, Semantics"];
Erlang -> Reia [label="Execution and Concurrency Semantics"];
Planner -> "Smalltalk-71" [label="Pattern-directed Execution"];
"Smalltalk-71" -> Actors [label="Message-directed Execution"];
Actors -> Erlang [label="Execution and Concurrency Semantics"];
Actors -> Reia [label="Execution and Concurrency Semantics"];
"Smalltalk-71" -> Smalltalk [label="Object Semantics"];
#!/usr/bin/env ruby
require 'fiber'
# This state machine corresponds to the regular expression /ab*(c|d)/
@start = Fiber.new do
loop do
case (@string.next rescue nil)
when 'a' then @state1.transfer