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
(comment " | |
SpeedNotes Clojure script, by Torbjørn Marø. | |
Version 1.0 - 2010.08.17 | |
Clojure version 1.1 (w/Contrib) | |
====================================================================== | |
Always have it running in a console window to quickly note down stuff | |
you need to remember - thoughts and ideas you don't want to loose, | |
but don't want to steal focus away from what you are currently doing | |
either. |
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 slime-update-namespace () | |
"Find the namespace in the current buffer and set the package of | |
the REPL buffer to PACKAGE." | |
(interactive) | |
(let ((package (slime-find-buffer-package))) | |
(if package | |
(slime-repl-set-package package) | |
(call-interactively 'slime-repl-set-package)))) |
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
(defconst java-import-regex "^[[:space:]]*import[[:space:]]+\\(.*\\)\\.\\(.*\\);") | |
(defun clojure-java-import-line-parse (line) | |
(unless (string-match java-import-regex line) | |
(error "No import line")) | |
(let ((package (match-string-no-properties 1 line)) | |
(symbol (match-string-no-properties 2 line))) | |
(list package symbol))) | |
(defun clojure-java-import-region (start end) |
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 mapmap | |
"Return a new map, mapping keys to (keyfn key) and mapping values to | |
(valfn val)" | |
([valfn map] | |
(mapmap identity valfn map)) | |
([keyfn valfn map] | |
(persistent! (reduce | |
(fn [c [k v]] (assoc! c (keyfn k) (valfn v))) | |
(transient {}) | |
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 sicp.queens) | |
(def empty-board '()) | |
(defn safe? | |
"Check if queen in last row is safe" | |
[positions] | |
(let [[queen-pos & left] positions | |
k (count positions) | |
diags-up (map - left (range 1 (inc k))) |
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
(defadvice shell-cd (after shell-dirtrack-update-buffer-name activate) | |
(let* ((new-name (generate-new-buffer-name "*shell*")) | |
(old-name (generate-new-buffer-name (buffer-name)))) | |
(unless (string= new-name old-name) | |
(rename-buffer new-name)))) |
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 #^{:author "Jürgen Hötzel", | |
:doc "Message Digest function for Clojure | |
Usage | |
(require 'md) | |
MD5 Checksum String: | |
(md/digest-str (md/sum \"MD5\" \"/etc/passwd\")) | |
\"85dbcf75fa3eb92335cc3ac47dfa64c9\""} | |
md |
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
(defvar swank-autoconnect-port 4005) | |
(defvar swank-autoconnect-timer nil) | |
(defun swank--listeningp () | |
(ignore-errors | |
(let ((p (open-network-stream "SLIME Lisp Connection Test" nil "localhost" swank-autoconnect-port))) | |
(when p | |
(delete-process p) | |
t)))) |
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
#!/bin/bash | |
ORIG_MVN=/opt/maven/bin/mvn | |
while [ ! -r "pom.xml" ] && [ "$PWD" != "/" ] | |
do | |
cd .. | |
done | |
if [ -r "pom.xml" ]; then |
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) |