Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Karsten Lang klang

🏠
Working from home
View GitHub Profile
@klang
klang / timemachine.sh
Created Aug 16, 2010
poor man's time machine. Works with in cygwin as well as any unix based environment that provides rsync.
View timemachine.sh
#!/bin/bash
semaphore() {
if [ -e $0.pid ]; then
PID=$(cat $0.pid)
fi
if [ $PID ]; then
echo $PID on file
PIDr=$( ps -ef | awk '{print $2}' | grep ^$PID$ )
@klang
klang / timemachine-host.sh
Created Aug 16, 2010
poor man's time capsule. Works with in cygwin as well as any unix based environment that provides rsync.
View timemachine-host.sh
#!/bin/bash
semaphore() {
if [ -e $0.pid ]; then
PID=$(cat $0.pid)
fi
if [ $PID ]; then
echo $PID on file
PIDr=$( ps -ef | awk '{print $2}' | grep ^$PID$ )
@klang
klang / exportjpg.pl
Created Aug 16, 2010
change size and quality of jpg/bmp pictures while keeping exifdata. The script makes a 'lightweight' version of original off-the-camera jpg pictures. The copy can be used for picture frames without taking up too much space.
View exportjpg.pl
#!/usr/bin/perl
use Getopt::Long;
use strict;
my $src = $ENV{'PWD'};
my $dst = "/cygdrive/c/pictures/export/digital";
my $quality = 75;
sub usage {
@klang
klang / luddite-mode.el
Created Aug 20, 2010
Luddite mode for emacs gives a few extra lines, when the tool-, menu- and scroll-bars are turned off.
View luddite-mode.el
;; first, remove all the crap that looks different from emacs 20.7.1
; luddite mode
(cond ((> emacs-major-version 20)
(tool-bar-mode -1) ; introduced in emacs 21
(menu-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-showhide-fringe-menu-customize-disable)
(blink-cursor-mode -1)
(windmove-default-keybindings 'meta)))
@klang
klang / what-parens-all-I-see-is-the-program.el
Created Sep 1, 2010
What parens? All I see is the program. (the Clojure color part of http://briancarper.net/blog/492/emacs-clojure-colors in one convenient place. Just dimming the parens: http://www.davep.org/emacs/parenface.el --- from: http://briancarper.net/blog/492/emac
View what-parens-all-I-see-is-the-program.el
(defun lisp-enable-paredit-hook () (paredit-mode 1))
(add-hook 'clojure-mode-hook 'lisp-enable-paredit-hook)
(defmacro defclojureface (name color desc &optional others)
`(defface ,name '((((class color)) (:foreground ,color ,@others))) ,desc :group 'faces))
(defclojureface clojure-parens "DimGrey" "Clojure parens")
(defclojureface clojure-braces "#49b2c7" "Clojure braces")
(defclojureface clojure-brackets "SteelBlue" "Clojure brackets")
(defclojureface clojure-keyword "khaki" "Clojure keywords")
View execute-buffer-script.el
;; runs the current buffer in the environment where the file resides.
(defvar extention-to-executer-bindings ())
(add-to-list 'extention-to-executer-bindings '("pl" . "perl"))
(add-to-list 'extention-to-executer-bindings '("php" . "php -f"))
(add-to-list 'extention-to-executer-bindings '("sh" . "bash"))
(defun lookup-executer (ext)
"find appropriate executer for script"
(interactive)
View dyslexic.pl
sub pirnt {print @_}
pirnt "hello world\n"
@klang
klang / hardlink-deps.sh
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.
View hardlink-deps.sh
@klang
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 "http://blog.carsoncheng.ca/2011/02/how-to-change-jpeg-compression-in.html"})
(:require clojure.java.io)
(: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])))