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 https://gist.github.com/2002582 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
(cemerick.piggieback/cljs-repl
:repl-env (doto (cljs.repl.browser/repl-env
:port 3000
:optimizations :whitespace
:src "src/cljs")
cljs.repl/-setup)
:eval cemerick.piggieback/cljs-eval)
View paredit.org

emacs/paredit commands for clojure

slime

C-x C-eslime-eval-last-expression
C-M-xlisp-eval-defun
C-c C-cslime-compile-defun
C-c C-kslime-compile-and-load-file
C-c C-lslime-load-file
M-.slime-edit-definition
M-,slime-pop-find-definition-stack
M-TABslime-complete-symbol
View import.sh
#!/bin/bash
cook=$1
: ${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 <thomasjack@gmail.com>
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> x.foo = 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
proxy.find(self.id)
when ActiveRecord::BelongsToAssociation
proxy.id == self.id
else
self.roles.include? role
end
end
You can’t perform that action at this time.