Skip to content

Instantly share code, notes, and snippets.


Herwig Hochleitner bendlas

  • Austria
View GitHub Profile
View timer.clj
(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."
View Fix for checked esceptions
class ExceptionAdapter extends RuntimeException {
private final String stackTrace;
public Exception originalException;
public ExceptionAdapter(Exception e) {
originalException = e;
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
stackTrace = sw.toString();
View Swank_clojure_setup_for_hardcore_Emacs_users.el
;; 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)
bendlas / gist:726251
Created Dec 2, 2010
test case for clojureql
View gist:726251
(use 'clojureql.core)
(def users (project (table server/*db* :user_view)
:lname :fname]))
(def groups (aggregate
(join (table server/*db* :groups)
(table :user_groups)
bendlas / gist:728427
Created Dec 4, 2010
Case for wrapped exception issue
View gist:728427
(defn failing []
(throw (IndexOutOfBoundsException. "Failed")))
(defn wrappy []
(catch Throwable e
(throw (IllegalArgumentException. "Wrapped Fail" e)))))
bendlas / gist:763393
Created Jan 3, 2011
First stab at a WITH RECURSIVE construct for ClojureQL
View gist:763393
(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)))
body# ~body-relation
step# ~step-relation
View gist:772953
(ns gist
(:require [clojureql.core :as cql]))
(def schema-tables
(cql/table *db* :information_schema.tables)
(cql/where (= :table_schema "public"))))
(def table-columns
View testbed.c
#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)
bendlas / emacs-merge-into
Created Oct 18, 2011
A wrapper to use ediff-merge-files as a system merge tool
View emacs-merge-into
if [ ${#argv} -eq 3 ]; then
emacs -Q -nw --eval "(ediff-merge-files \"$2\" \"$3\" nil \"$1\")"
exit $?
View sicp.clj
(defn fast-expt [b n]
(loop [acc 1
b b
n n]
(= n 0) acc
(even? n) (recur acc (* b b) (/ n 2))
:else (recur (* acc b) b (dec n)))))
(defn mult [a b]