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
(defproject hello-world "1.0.0-SNAPSHOT" | |
:description "FIXME: write" | |
:dependencies [[org.clojure/clojure "1.1.0"] | |
[org.clojure/clojure-contrib "1.1.0"] | |
[compojure "0.4.0-SNAPSHOT"] | |
[ring/ring-jetty-adapter "0.2.0"]]) |
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 life (:use clojure.test clojure.set)) | |
(def under-populated 1) | |
(def over-populated 4) | |
(def fertile 3) | |
(defn north [[x y]] [x (inc y)]) | |
(defn south [[x y]] [x (dec y)]) | |
(defn east [[x y]] [(inc x) y]) | |
(defn west [[x y]] [(dec x) y]) |
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
(defun smart-line-beginning () | |
"Move point to the beginning of text on the current line; if that is already the current position of point, then move it to the beginning of the line." | |
(interactive) | |
(let ((pt (point))) | |
(beginning-of-line-text) | |
(when (eq pt (point)) | |
(beginning-of-line)))) | |
(global-set-key "\C-a" 'smart-beginning-of-line) |
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
(defn list-classes [bytes] | |
(with-open [jar-is (JarInputStream. (java.io.ByteArrayInputStream. bytes))] | |
(doall (map | |
(fn [entry] (-> (.getName entry) | |
(.replaceAll "\\.class$" "") | |
(.replaceAll "/" "."))) | |
(filter | |
#(.endsWith (.getName %) ".class") | |
(take-while identity (repeatedly #(.getNextEntry jar-is)))))))) |
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
(set! *unchecked-math* true) | |
(defmacro iloop [[b t n] & body] | |
`(loop [~@b] | |
(when ~t | |
~@body | |
(recur ~n)))) | |
(defn count-primes [^long n] | |
(let [c (inc n) |
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
(defmacro defconst [const-name const-val] | |
`(def | |
~(with-meta const-name | |
(assoc (meta const-name) :const true)) | |
~const-val)) | |
(defmacro defconsts [bindings] | |
`(do | |
~@(map (fn [[const-name const-val]] | |
`(defconst ~const-name ~const-val)) |
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 tetris.core | |
(:import (java.awt Color Dimension BorderLayout) | |
(javax.swing JPanel JFrame JOptionPane JButton JLabel) | |
(java.awt.event KeyListener)) | |
(:use clojure.contrib.import-static deflayout.core | |
clojure.contrib.swing-utils) | |
(:gen-class)) | |
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_DOWN VK_UP VK_SPACE) |
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
(defn get-hash [type data] | |
(.digest (java.security.MessageDigest/getInstance type) (.getBytes data) )) | |
(defn sha1-hash [data] | |
(get-hash "sha1" data)) | |
(defn get-hash-str [data-bytes] | |
(apply str | |
(map | |
#(.substring |
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
(deftheme bubbleberry "bubbleberry") | |
;; Based on the theme used for LightTable (see: http://www.chris-granger.com/images/lightable/main.png ) | |
(custom-theme-set-variables | |
'bubbleberry | |
'(linum-format " %7i ") | |
'(fringe-mode 5 nil (fringe)) | |
'(powerline-color1 "#3d3d68") | |
'(powerline-color2 "#292945") |
OlderNewer