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
def woopfordocstrings(): | |
'''this is a docstring''' | |
print "sausages" |
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
watch( 'test/.*\.clj' ) {|md| test_stuff } | |
watch( 'src/.*\.clj' ) {|md| test_stuff } | |
def colorize(text, color_code) | |
"#{color_code}#{text}\e[1;37m" | |
end | |
def red(text); colorize(text, "\e[0;31m"); end | |
def green(text); colorize(text, "\e[0;32m"); 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
; Answers http://www.rubyquiz.com/quiz76.html | |
(defn text-munger [string] | |
(for [word (re-split #"\s" string)] | |
(if (> (count word) 3) | |
(let [start (first word) | |
end (last word)] | |
(str start (reduce str (shuffle (drop 1 (take (- (count word) 1) word)))) | |
end)) word))) |
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
(defun my-run-tests () | |
(interactive) | |
(let ((test-buffer (find-buffer-visiting (format "%stest/%s-test.clj" | |
(locate-dominating-file buffer-file-name "src/") | |
(file-name-nondirectory (file-name-sans-extension buffer-file-name)))))) | |
(save-buffer) | |
(with-current-buffer test-buffer | |
(clojure-test-run-tests)) | |
(sit 1) | |
(if |
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
(defun flash-modeline (color) | |
(setq old-background-face (copy-face 'modeline 'old-background-face)) | |
(setq old-buffer-id-face (copy-face 'modeline-buffer-id 'old-buffer-id-face)) | |
(set-face-to-one-color 'modeline color) | |
(set-face-to-one-color 'modeline-buffer-id color) | |
(sit-for 1) | |
(set-face-background 'mode-line (face-background old-background-face)) | |
(set-face-foreground 'mode-line (face-foreground old-background-face)) | |
(set-face-background 'mode-line-buffer-id (face-background old-buffer-id-face)) | |
(set-face-foreground 'mode-line-buffer-id (face-foreground old-buffer-id-face)) |
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
a Java array | |
agt an agent | |
coll a collection | |
expr an expression | |
f a function | |
idx an index | |
r a ref | |
v a vector | |
val a value | |
pred a predicate |
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 string_calculator | |
(:use clojure.contrib.str-utils)) | |
(defn add-numbers [s] | |
(reduce + (map #(check-num %) | |
(filter #(not= "" %) (re-split #"," s))))) | |
(defn check-num [i] | |
(let [intr (Integer. i)] | |
(if (> 0 intr) |
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
<xml> | |
<defun name="qsort"> | |
<args> | |
<required-arg name="lis" /> | |
<optional-args> | |
<optional-arg name="less" default="nil"/> | |
<optional-arg name="greater" default="nil"/> | |
</optional-args> | |
</args> | |
<cond> |
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
(use 'clojure.contrib.seq-utils) | |
(use 'clojure.walk) | |
(import '(java.io File LineNumberReader InputStreamReader PushbackReader) | |
'(java.lang.reflect Modifier Method Constructor) | |
'(clojure.lang RT Compiler Compiler$C)) | |
;; Yoinked and modified from clojure.contrib.repl-utils. | |
;; Now takes a var instead of a sym in the current ns | |
(defn get-source-from-var | |
"Returns a string of the source code for the given symbol, if it can |
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
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Comparator; | |
public class KalaTournament { | |
private enum WIN_FLAG { | |
PLAYER_0, PLAYER_1, DRAW | |
} | |
private static class AIComparer implements Comparator<KalaPlayer> { |
OlderNewer