Skip to content

Instantly share code, notes, and snippets.

View klang's full-sized avatar
🏠
Working from home

Karsten Lang klang

🏠
Working from home
View GitHub Profile
@klang
klang / README
Created February 25, 2016 07:49
a control loop keeping several threads alive
virtualenv -p $(which python3) venv
source venv/bin/activate
(venv)[klang@ergates workers]$ python -i tester_run.py
>>>
@klang
klang / docker_with_oracle.md
Last active February 3, 2016 07:43
t2.micro amazon linux instance with docker running an oracle xe 11g instance for RDS imports

export RDSHELPER=the_ip_address_of_the_t2.micro_to_be_used

install docker

ssh -i ~/.ssh/e2ckey.pem ec2-user@$RDSHELPER
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
exit
@klang
klang / fof.clj
Created October 14, 2013 14:11
FOF teacher of the year. Standing by number of nominations. (using enlive to fetch the relevant data from the html page and a part of a general map/reduce pattern to calculate the result)
(ns sandbox.fof
(:require [net.cgrand.enlive-html :as html]))
(defn fetch-url [url]
(html/html-resource (java.net.URL. url)))
(def nom (fetch-url "http://www.asp.fof.dk/aaretsunderviser.asp#.Ulvs8RbNdcx"))
(defn parse [nom]
(map #(vector % 1) (map html/text (html/select nom [:b]))))
@klang
klang / .bash_finder
Created October 4, 2013 11:54
shortcut to open GUI folder for the current (or other) location from a shell
# -*- mode: sh -*-
# add the following line to .bash_profile
# . .bash_finder
## opens a standard file explorer window at the current location
## e - just a window at current location
function e {
if [ $# -eq 0 ]; then
@klang
klang / learn-datalog.edn
Created August 27, 2013 06:21
Learn datolog today
;; http://www.learndatalogtoday.org/
;; Find movie titles made in 1985
[:find ?title
:where
[?m :movie/year 1985]
[?m :movie/title ?title]]
;; What year was "Alien" released?
[:find ?year
@klang
klang / split-destination
Last active December 21, 2015 10:29
An easy way to get data back from a full destination string.
./split_destination-test.sh
destination user@host.with.full.domain:/full/path/to/install/package.ext
server host.with.full.domain
servershort host
user user
fullpath /full/path/to/install/package.ext
path /full/path/to/install/
package package.ext
sub untaint {
my $data = shift;
return $data if !$data;
if ($data =~ /^([-\@\w\d\/\.]+)\r*$/) {
$data = $1; # $data now untainted
} else {
die "Tainted data in $data\n"; # log this somewhere
}
return $data;
}
@klang
klang / init-emacs23.el
Created May 28, 2013 05:37
windows 7 config for emacs
;; ~/.emacs.d/elisp
;; ~/.emacs.d/package.el
;; ln -s ~/.emacs.d/elisp/init.el ~/.emacs.d/init.el
(and (= emacs-major-version 23)
(defun server-ensure-safe-dir (dir) "Noop" t))
;; (getenv "APPDATA")
;; (getenv "HOME")
;;(and (= emacs-major-version 23)
;; (add-to-list 'load-path (getenv "APPDATA"))
##echo "emacsclient"
### cygwin magic
## new-frame - make a new emacs frame
## edit-new-frame file - edit file in new emacs frame
## edit file - edit file in existing emacs frame
# http://www.emacswiki.org/emacs/EmacsClient
function new-frame() {
@klang
klang / mapping.clj
Created May 23, 2013 09:57
simple mapping in clojure
(ns scratch.mapping)
(defstruct Book :title :author :publisher)
(defstruct Author :firstName :lastName)
(defstruct Publisher :name)
(def books [(struct Book
"The Reality Dysfunction"
(struct Author "Peter F." "Hamilton")
(struct Publisher "Pan Books"))