Skip to content

Instantly share code, notes, and snippets.

@drankard
drankard / pull-request
Created October 29, 2010 12:14
hvordan man udfører en pull request
Step 1: Check out a new branch to test the changes — run this from your project directory
git checkout -b drankard-master master
Step 2: Bring in drankard's changes and test
git pull [email protected]:drankard/kunde.git master
Step 3: Merge the changes and update the server
git checkout master
git merge drankard-master
@drankard
drankard / file-walk.clj
Created November 4, 2010 15:54
Some general filesystem crawler functions
(ns order.docs
(:import java.io.File)
(:import java.io.FileNotFoundException))
(defn as-file [s]
"Return whatever we have as a java.io.File object"
(cond (instance? File s) s ; already a file, return unchanged
(string? s) (File. s) ; return java.io.File for path s
:else (throw (FileNotFoundException. (str s)))))
@drankard
drankard / setup-emacs
Created November 7, 2010 12:50
setup elpa package manager M-x ielm and paste
(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer))))
@drankard
drankard / .emacs
Created November 15, 2010 08:09
emacs toggle-fullscreen incl. f11 binding
(defun toggle-fullscreen (&optional f)
(interactive)
(let ((current-value (frame-parameter nil 'fullscreen)))
(set-frame-parameter nil 'fullscreen
(if (equal 'fullboth current-value)
(if (boundp 'old-fullscreen) old-fullscreen nil)
(progn (setq old-fullscreen current-value)
'fullboth)))))
(global-set-key [f11] 'toggle-fullscreen)
@drankard
drankard / .emacs
Created November 23, 2010 16:52
my current .emacs file
;(require 'color-theme)
;;; Emacs Load Path
;(setq load-path (push "~/.emacs.d/" load-path))
(setq browse-url-generic-program (executable-find "google-chrome")
browse-url-browser-function 'browse-url-generic)
;; Convert TAB to SPACE.
(setq-default indent-tabs-mode nil)
@drankard
drankard / Global.sublime-settings
Created October 17, 2011 10:13
Sublime Text user prefs
// Place user-specific overrides in this file, to ensure they're preserved
// when upgrading
{
"folder_exclude_patterns": [".*","classes","lib"],
"file_exclude_patterns": [".*", "*.swp","*.jar","pom.xml"]
}
@drankard
drankard / with-query-results-cursor
Created November 3, 2011 08:31
clojure jdbc - query with cursor
(def *default-fetch-size* 500)
(defn with-query-results-cursor [[sql & params :as sql-params] func]
(sql/transaction
(with-open [stmt (.prepareStatement (sql/connection) sql)]
(doseq [[index value] (map vector (iterate inc 1) params)]
(.setObject stmt index value))
(.setFetchSize stmt *default-fetch-size*)
(with-open [rset (.executeQuery stmt)]
(func (resultset-seq rset))))))
@drankard
drankard / or=
Created November 11, 2011 13:00
Clojure or equals func (or= expr & args)
(defn or= [expr & args]
(some #(= expr %) args))
@drankard
drankard / tester.clj
Created December 14, 2011 22:31
clojure rdf test
(ns rdf-bi.core)
(defn dc [property]
(str "http://purl.org/dc/elements/1.1/contributor/" (name property)))
(defn rdfs [property]
(str "http://www.w3.org/2000/01/rdf-schema#" (name property)))
(defn rdf [property]
@drankard
drankard / sleep.clj
Created September 3, 2012 18:01
if you ever need a Thread/sleep xx
I tried running (Thread/sleep 1000) on my VM os.. which returned randomly between 5 30 seconds..
to be sure..:
(let [o (Object.)] (locking o (. o wait 1000)))