Skip to content

Instantly share code, notes, and snippets.

Working from home

Karsten Lang klang

Working from home
View GitHub Profile
klang /
Created Sep 26, 2010
changes physical files in lib and lib/dev to be hardlinks back to the maven repository living in ~/.m2 .. to reduce disk space used in a setting where _a lot_ of Clojure projects using Leiningen is tried in a limited disk space setting.
klang / compress_jpg.clj
Created Feb 20, 2011
change compression level without losing the metadata of a jpg file
View compress_jpg.clj
(ns sandbox.compress-jpg
(meta {:description "change compression level without losing the metadata of a jpg file"
:url ""})
(:import [javax.imageio IIOImage ImageIO]
[javax.imageio.plugins.jpeg JPEGImageWriteParam]))
(defn compress-jpg [inputFile outputFile compressionQuality]
(let [image-reader (.next (ImageIO/getImageReadersByFormatName "jpg"))
image-writer (.next (ImageIO/getImageWritersByFormatName "jpg"))]
View fibos.clj
(defn fibos []
(map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
klang / slime-override-mode
Created May 22, 2011
Slime-override-mode to fix paredit-(open|close)-(round|square|curly) and move the keys
View slime-override-mode
;; {} are not handled correctly by paredit in the repl,
;; but these lines fixes it
(defvar slime-override-map (make-keymap))
(define-minor-mode slime-override-mode
"Fix SLIME REPL keybindings"
nil " SLIME-override" slime-override-map)
(define-key slime-override-map (kbd "<C-return>") 'paredit-newline)
(define-key slime-override-map (kbd "{") 'paredit-open-curly)
klang / scope.php
Created Jun 1, 2011
wierd scope rules in php
View scope.php
function test() {
global $data;
$data = array(1,2,3);
View one_liners.clj
(ns one-lineres)
;; 1. Multiple Each Item in a List by 2
(map #(* 2 %) (range 1 11))
;; 2. Sum a List of Numbers
(reduce + (range 1 1001))
;; 3. Verify if Exists in a String
(def words #{"scala" "akka" "play framework" "sbt" "typesafe"})
klang / foo.html
Created Jan 10, 2012
html array send to php action
View foo.html
<script type="text/javascript">
function btnClick(aBtn) {
with (aBtn.form) {
event.value =;
klang / toggle-related-files.el
Created Jun 1, 2012
Quick and dirty way to define a toggle between related files in emacs
View toggle-related-files.el
klang /
Created Sep 15, 2012
git repository on dropbox
export DROPBOX=~/Dropbox/repos
export newRepo=project-name
export NAME=$(git config --global --get
cd ~/projects/$newRepo
git init
git add .
git commit -m 'initial'
klang /
Created Dec 21, 2012
A simple little script to observe selected users activity on the system. When conducting training sessions, it's sometimes necessary to have your mother watching over you ..
@users = ( 'klang' );
my $procs = qx/ps -ef/;
#my $login = qx/last/;
foreach my $user (@users) {
while ($procs =~ m/^ *(\w*).+ .:.. (.+)$/gm) {
my $usr = $1;
my $proc = $2;