Skip to content

Instantly share code, notes, and snippets.

View klang's full-sized avatar
🏠
Working from the office

Karsten Lang klang

🏠
Working from the office
View GitHub Profile
@klang
klang / F.sql
Last active August 29, 2015 13:56
code text added to database with f.sql and extracted with dump_source.sql, resulting in F.sql (notice uppercase) .. Seen from a versioning system (git) perspective, most of the lines in the original source have changed. The lines containing "begin" and "end;" are the only ones that are unchanged. Git's model state that, if the SHA-1 of the conte…
CREATE OR REPLACE FUNCTION "ORACLEGIT"."F" return varchar as
begin
return
'Hello world';
end;
#!/bin/sh
# a quick & dirty script to create a TinyCore initrd (for Core >= 4.2)
H=$( pwd )
M=$( mount | grep iso9660 | head -1 | awk '{print $3}' )
[ -z "$M" ] && echo "can not find mounted CD-ROM" && exit 1
D=$( mktemp -d )
@klang
klang / post-receive
Created March 25, 2014 07:32
hook to automatically deploy an app, when pushes to a repository is made. The script has to be placed in .git/hooks/post-receive and made executable. Script taken from: http://www.sitepoint.com/one-click-app-deployment-server-side-git-hooks/
#!/bin/sh
# blog post: http://www.sitepoint.com/one-click-app-deployment-server-side-git-hooks/
## store the arguments given to the script
read oldrev newrev refname
## Where to store the log information about the updates
LOGFILE=./post-receive.log
# The deployed directory (the running site)
DEPLOYDIR=/var/www/html/simpleapp

Git attributes for .docx diffing

docx2txt

Download and install the docx2txt converter from http://docx2txt.sourceforge.net/

wget -O doc2txt.tar.gz http://docx2txt.cvs.sourceforge.net/viewvc/docx2txt/?view=tar
tar zxf docx2txt.tar.gz
cd docx2txt/docx2txt/

sudo make

@klang
klang / strange_python.py
Created September 9, 2014 06:36
Python oddities
# array
>>> [1]
[1]
>>> [1,]
[1]
# hash
>>> {'a':1}
{'a': 1}
>>> {'a':1,}
@klang
klang / dynamodb.org
Created April 10, 2015 09:04
Example usage of DynamoDB from the cli (inside emacs, via org-mode)

Set up the environment

(setq org-confirm-babel-evaluate nil)
(setq org-babel-sh-command "ssh default ")
;; customize the following variables:
;;(setq org-babel-load-languages 
;;<<< '((emacs-lisp . t) (python . t) (clojure . t) (sh . t ) (perl . t)))
@klang
klang / cloudformation-vpc-from-scratch.json
Created April 19, 2015 18:40
A CloudFormation test template to create a VPC with a public subnet and spin up a internet connected instance inside of it.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Building a VPC from scratch with CloudFormation",
"Mappings": {
"SubnetConfig": {
"VPC": { "CIDR": "10.0.0.0/16" },
"Public": { "CIDR": "10.0.0.0/24" }
},
"RegionMap" : {
@klang
klang / GitSha1.java
Created July 14, 2015 09:37
git hash
import org.apache.commons.codec.digest.DigestUtils;
public class GitSha1 {
public static String githash(String aString){
return DigestUtils.sha1Hex("blob " + aString.length() + "\0" + aString);
}
public static void main(String[] args) {
We have the situation, where a cvs server is not available from a development host, but the development host
is available from the cvs server:
.-----.
| PC |
.-----.
/ \
v v
.-----. .-----.
| cvs |------>| dev |
@klang
klang / monitor.clj
Created November 12, 2015 08:01
Log monitoring and processing
(ns monitor
(:gen-class)
(:import (java.io RandomAccessFile)))
(def sleep-interval 2000)
(defn extract-ip-address [message]
(if (not (nil? message))
(let [pattern "(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}) ([0-9a-f]+\\.[0-9a-f]+\\.[0-9a-f]+) via (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})"
message-seq (first (re-seq (re-pattern pattern) message))