Skip to content

Instantly share code, notes, and snippets.

View klang's full-sized avatar
🏠
Working from home

Karsten Lang klang

🏠
Working from home
View GitHub Profile
(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"]])
@juergenhoetzel
juergenhoetzel / lein-swank.el
Created May 30, 2010 22:20
Launch a Leiningen Swank Process and connect
We couldn’t find that file to show.
(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])
@amalloy
amalloy / .emacs
Created September 27, 2010 20:33
(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)
(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))))))))
(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)
@blacktaxi
blacktaxi / const-macros.clj
Created February 7, 2012 15:48
Macros for defining constants in Clojure
(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))
@alexander-yakushev
alexander-yakushev / tetris.clj
Created September 10, 2011 00:28
Tetris implementation in Clojure
(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)
@prasincs
prasincs / sha1-hash.clj
Created February 15, 2011 08:36
clojure sha1 hash
(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
(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")