Skip to content

Instantly share code, notes, and snippets.

Tom Jack tomjack

Block or report user

Report or block tomjack

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:4648346
;;; example of using extent rules on explicit data, or to filter a db
;; from qv
user> (def extent-rules
'[[(extent ?x ?e ?a ?v) ;; match datoms where x is entity...
[?e ?a ?v]
[?x ?a ?v]
[(= ?e ?x)]]
[(extent ?x ?e ?a ?v) ;; ...or match datoms where x is value
[?e ?a ?v]
View gist:3412542
:repl-env (doto (cljs.repl.browser/repl-env
:port 3000
:optimizations :whitespace
:src "src/cljs")
:eval cemerick.piggieback/cljs-eval)

emacs/paredit commands for clojure


C-x C-eslime-eval-last-expression
C-c C-cslime-compile-defun
C-c C-kslime-compile-and-load-file
C-c C-lslime-load-file
: ${OPSCODE_COOKBOOKS:="/path/to/opscode/cookbooks"}
cp -r $OPSCODE_COOKBOOKS/$cook .
git add $cook
version=`cat $cook/metadata.rb | grep version | tr -d '"' | tr -s ' ' | cut -d ' ' -f 2`
git commit -m "Import $cook version $version"
git branch chef-vendor-$cook
git tag cookbook-site-imported-$cook-$version
View .stumpwmrc
(defcommand scroll-conkeror-down () ()
(run-shell-command "conkeror -batch -f cmd_scrollPageDown"))
(define-key *top-map* (kbd"s-SPC") "scroll-conkeror-down")
View factorial.hs
import Data.List (foldl')
import qualified Data.ByteString.Lazy.Char8 as C
zeros n = foldl' (+) 0 $ takeWhile (> 0) $ map (\e -> floor (n / 5^e)) [1..]
main = do
input <- C.getContents
let inputLines = C.lines input
numData = case C.readInt $ head inputLines of
Just (n,_) -> n
View lcm.clj
(defn prime? [n]
(every? #(pos? (mod n %)) (range 2 n)))
(defn next-prime [n]
(first (drop-while (complement prime?) (iterate inc (inc n)))))
(defn factor-multiplicity
([n d]
(factor-multiplicity n d 0))
([n d acc]
View 0001-allow-multiple-not-null-fields-with-postgres.patch
From a4e9c6077528282cf3ce3a2fe28d39fa9932001d Mon Sep 17 00:00:00 2001
From: Thomas Jack <>
Date: Thu, 15 Oct 2009 01:44:32 -0500
Subject: [PATCH] allow multiple 'not-null' fields with postgres
src/dk/bestinclass/clojureql/backend/postgres.clj | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/dk/bestinclass/clojureql/backend/postgres.clj b/src/dk/bestinclass/clojureql/backend/postgres.clj
View *scratch*
[tomoj@skami ~]$ irb
irb(main):001:0> class Fixnum
irb(main):002:1> attr_accessor :foo
irb(main):003:1> end
=> nil
irb(main):004:0> def foo(x)
irb(main):005:1> = 23
irb(main):006:1> end
=> nil
irb(main):007:0> a = 3
View gist:187812
def has_role?(role, object)
case proxy = object.send(role)
when ActiveRecord::AssociationCollection
when ActiveRecord::BelongsToAssociation ==
self.roles.include? role
You can’t perform that action at this time.