This file contains 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
describe("Player", function() { | |
var player; | |
// hook before each test | |
beforeEach(function(){ | |
player = new Player(); | |
spyOn(loading,'show'); // intercept and record calls to loading.show | |
player.play(); | |
}); | |
// actual specifications/tests |
This file contains 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
;; http://www.johndcook.com/blog/2012/05/08/a-knights-random-walk/ | |
;; | |
;; Start a knight at a corner square of an otherwise-empty chessboard. Move the | |
;; knight at random by choosing uniformly from the legal knight-moves at each | |
;; step. What is the mean number of moves until the knight returns to the | |
;; starting square? | |
(def MAXPOS 7) | |
; (pos, move) -> pos |
This file contains 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 python | |
""" This is a simulation of ants moving woodchips around | |
using the pyscape classes. Hopefully it demonstrates the | |
construction of central clusters using only decentralized | |
algorithms followed by autonomous agents. | |
We begin with a scattering of woodchips across the grid. | |
Ants randomly walk around, following a simple rule: | |
if you see a woodchip: |
This file contains 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
-- a more verbose and explanatory version of this one-liner | |
-- main = interact $ unlines . map reverse . lines | |
-- we're going to use some library functions: | |
-- lines :: String -> [String] | |
-- unlines :: [String] -> String | |
-- reverse :: [a] -> [a] | |
-- reverse works on arbitrary lists, and Strings are [Char]. | |
-- let ... in allows you to bind names to values, |
This file contains 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
nathan@hugin:~/p/haskell/tidbits$ cat quine.hs | |
q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')'] | |
main=q "q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')']" "def q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'" "def e(x) return 34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q '+e(b)+' '+e(c)+' '+e(a)+' '+10.chr end" | |
nathan@hugin:~/p/haskell/tidbits$ runghc quine.hs | |
def q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')' | |
q("def q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'","def e(x) return 34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q '+e(b)+' '+e(c)+' '+e(a)+' '+10.chr end","q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')']") | |
This file contains 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 python | |
import random | |
from math import * | |
# This is an attempt at solving the travelling salesperson problem | |
# with simulated annealing. I tried this once in matlab and it sucked. | |
# a map is a list of tuples, one tuple for each city. | |
# each tuple represents the (x,y) location of a city on the map. |
This file contains 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 lazybot.plugins.greetings | |
(:use lazybot.registry) | |
(:use [lazybot.utilities :only [prefix]]) | |
(:require [clojure.string :as s])) | |
(def morning-patterns | |
[#".*good.morning.*" | |
#".*top.*o.*morning.*" | |
]) |
This file contains 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 big-ben.core | |
(:use [clj-time.core :exclude [extend]] | |
[clj-time.local]) | |
(:require [irclj.core :as ircb] | |
[overtone.at-at :as at-at] | |
[clojure.string :as string])) | |
(def HOUR-IN-MS (* 60 60 1000)) | |
(def config |
This file contains 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 simplebot.core | |
(:use [clj-time.core :exclude [extend]] | |
[clj-time.local]) | |
(:require [irclj.core :as ircb] | |
[overtone.at-at :as at-at] | |
[clojure.string :as string])) | |
(def CHANNEL "#silly-bot-test") | |
(defn -main [& args] |
This file contains 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 lazybot.plugins.feelings | |
(:require [clojure.string :as string]) | |
(:use [lazybot registry] | |
[somnium.congomongo :only [fetch fetch-one insert! destroy!]])) | |
; feelings.clj: a lazybot plugin to remember and report how people feel about various stuff | |
; TODO: parameterize prefix instead of literal '@', or don't bother? | |
(def love-responses |
OlderNewer