Skip to content

Instantly share code, notes, and snippets.

(def gray 0)
(def black 1)
(def white 2)
(defn board [size] (vec (repeat * size size) gray))
# !
return (a > b)
# !!
if (a > b)
return true
else
return false
# !!!
#!/bin/bash -x
source ~/.bashrc
rvm use 1.9.2@project
bundle install
rake db:migrate
rake spec
HEADLESS=true rake cucumber
# add this code to "features/support/env.rb"
if ENV['HEADLESS'] == 'true'
require 'headless'
headless = Headless.new
headless.start
at_exit do
headless.destroy
end
# install Firefox, or any other browser under testing
apt-get install firefox
# install Xvfb
apt-get install xvfb
# boost X11 server
Xvfb :99 -ac -screen 0 1024x768x16
# set up environmental variable
export DISPLAY=:99
# launch Firefox
firefox
@naush
naush / make-command.clj
Created December 20, 2010 18:18
gtp implementation detail
(defmacro- make-command [name block]
`(defn ~(symbol name) [& args#]
(if args# (~block args#) (~block))))
@naush
naush / console.clj
Created December 20, 2010 17:54
gtp implementation example
(ns gtp.example.console
(:refer-clojure :exclude [name])
(:require [gtp.core :as gtp] :reload)
(:gen-class))
(defn board []
(let [size (atom 19)]
{:set-size #(reset! size %1)
:get-size @size}))
module UI.TestMenu where
import TestHelper
import HUnit.HUnit
import UI.Menu as Menu
gets move = return move
testAskMove = TestCase (do move <- askMove $ gets 0
assertEqual "should return 0," 0 move)
module UI.TestMenu where
import TestHelper
import HUnit.HUnit
import UI.Menu as Menu
mockBoard = "+++++++++"
mockFormatBoard board = board
testPrint expected actual = expected == actual
module UI.Menu (putBoard) where
-- putBoard format board = putStr $ format board
putBoard puts format board = puts $ format board
-- askMove = return =<< getLine
askMove gets = return =<< gets