This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Things that were invented in Smalltalk: | |
OOP | |
WIMP GUIs: Windows, Icons, Menus and a Pointing device | |
IDEs | |
Interactive debugger | |
Image-based VM | |
Blocks/closures | |
Message passing | |
Class browsers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn transfer | |
"Transfer a request to be handled as if it were for a different URI, but don't tell the client" | |
[req uri handler] | |
(if (= (:redirected-to req) uri) | |
(throw (Exception. (str "Already redirected to " uri "... no loops allowed"))) | |
(handler (assoc req :uri uri :redirected-to uri)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns rec-print) | |
(defn rec-pr-str | |
"Print record to string with type information" | |
[r] | |
(let [class-name (.getName (class r))] | |
(pr-str (merge {::rec-class class-name} r)))) | |
(def lookup-class | |
(memoize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
show_unmerged = ARGV[0] == '-u' | |
branches = `git branch -r`.split("\n") | |
branches.each do |branch| | |
is_merged = `git branch --contains #{branch}` =~ /master/ | |
puts branch if show_unmerged ^ is_merged | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# edit this list, or set GSD_SITES to add your custom sites | |
SITES="$GSD_SITES reddit.com forums.somethingawful.com somethingawful.com digg.com break.com news.ycombinator.com infoq.com bebo.com twitter.com facebook.com blip.com youtube.com vimeo.com delicious.com flickr.com friendster.com hi5.com linkedin.com livejournal.com meetup.com myspace.com plurk.com stickam.com stumbleupon.com yelp.com slashdot.com" | |
HOSTFILE="/etc/hosts" | |
if [ ! -w $HOSTFILE ] | |
then | |
echo "cannot write to $HOSTFILE, try running with sudo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# hook to enforce that current branch is up-to-date with latest | |
# changes from master before committing | |
# put me in .git/hooks and make me executable | |
# the output of rev-list in the following test will be empty if there | |
# are no commits in master that aren't in the current branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns markov | |
(use clojure.test)) | |
;; ---------- basic markov chain utils and API ---------- | |
(defn n-grams | |
"Partition seq s into all sequential groups of n items" | |
[n s] | |
(partition n 1 (repeat nil) s)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns trie.core | |
(:refer-clojure :exclude (merge contains?)) | |
(:use clojure.test)) | |
;; some generic trie (prefix tree) functions | |
(def box list) | |
(defn trie | |
"Returns trie for single seq s" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn watch | |
"Returns (running) thread which observes the value of f every delay | |
milliseconds, and calls the callback fn if the value changes. callback | |
will be called with the old and new values from f" | |
([f callback delay] | |
(let [proc (fn [] | |
(loop [x1 ::watch-init] | |
(let [x2 (f)] | |
(when (not= x1 x2) | |
(callback x1 x2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn timestamp | |
"Returns object timestamped with the current system time in milliseconds" | |
[obj millis] | |
(assoc obj :timestamp (System/currentTimeMillis))) | |
(defn new-model-object | |
"Returns new, uniquely identified, timestamped object with initial | |
key-val pairs" | |
[& key-vals] | |
(timestamp (merge (apply hash-map kvs) |