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 timer | |
(:import [java.util Timer TimerTask])) | |
(def the-timer (Timer.)) | |
(defn timer | |
"Schedules a callback for delayed execution. | |
Returns a function, that accepts a parameter: | |
:bump to restart the timer, returning true only if timer was active, hence was extended by that call | |
:cancel to abort the timer, returning true only if timer was active, hence was canceled b.t.c." |
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
import java.io.*; | |
class ExceptionAdapter extends RuntimeException { | |
private final String stackTrace; | |
public Exception originalException; | |
public ExceptionAdapter(Exception e) { | |
super(e.toString()); | |
originalException = e; | |
StringWriter sw = new StringWriter(); | |
e.printStackTrace(new PrintWriter(sw)); | |
stackTrace = sw.toString(); |
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
;; First fetch CVS version of slime, git version of clojure, swank-clojure, clojure-contrib and clojure-mode | |
;; Create ~/bin/clojure script which starts clojure repl and adds clojure-contrib src dir and swank-clojure src dir to classpath. I used clj-env helper from clojure-contrib | |
(pushnew '("\.clj$" . clojure-mode) auto-mode-alist) | |
(require 'clojure-mode) | |
;;;; Slime configuration stuff | |
(setf slime-lisp-implementations | |
'((ecl("~/bin/ecl" "--heap-size" "1024000000") :coding-system utf-8-unix) |
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
(use 'clojureql.core) | |
(def users (project (table server/*db* :user_view) | |
[:user_id | |
:lname :fname])) | |
(def groups (aggregate | |
(join (table server/*db* :groups) | |
(table :user_groups) | |
:group_id) |
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 wrap.fail) | |
(defn failing [] | |
(throw (IndexOutOfBoundsException. "Failed"))) | |
(defn wrappy [] | |
(try | |
(failing) | |
(catch Throwable e | |
(throw (IllegalArgumentException. "Wrapped Fail" e))))) |
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
;; http://www.postgresql.org/docs/9.0/static/queries-with.html | |
(defmacro with-recursive [rectable cols [start-relation union step-relation] body-relation] | |
;; store info in meta data, since compile doesn't dispatch on relation type | |
`(let [start# ~start-relation | |
~rectable (project (table ~(keyword (name rectable))) | |
~cols) | |
body# ~body-relation | |
step# ~step-relation |
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 gist | |
(:require [clojureql.core :as cql])) | |
(def schema-tables | |
(cql/select | |
(cql/table *db* :information_schema.tables) | |
(cql/where (= :table_schema "public")))) | |
(def table-columns | |
(cql/project |
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
#include <time.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <string.h> | |
// defined in asma.s | |
unsigned char *asma(unsigned char *s); | |
unsigned char *asma_ref(unsigned char *s) | |
{ |
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/zsh | |
if [ ${#argv} -eq 3 ]; then | |
emacs -Q -nw --eval "(ediff-merge-files \"$2\" \"$3\" nil \"$1\")" | |
exit $? |
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 fast-expt [b n] | |
(loop [acc 1 | |
b b | |
n n] | |
(cond | |
(= n 0) acc | |
(even? n) (recur acc (* b b) (/ n 2)) | |
:else (recur (* acc b) b (dec n))))) | |
(defn mult [a b] |
OlderNewer