Skip to content

Instantly share code, notes, and snippets.

View chklauser's full-sized avatar

Christian Klauser chklauser

View GitHub Profile
@chklauser
chklauser / ui_csp.pxs
Created March 6, 2012 10:31
Non-working example of a CSP+Text UI in Prexonite Script (bug in select?)
build does require(
@"psr\struct.pxs",
@"psr\console.pxs",
@"psr\csp.pxs",
@"psr\queue.pxs",
);
function create_tracer() {
chans(
var shutdown_c,
@chklauser
chklauser / Manage-AppConfig.ps1
Created July 22, 2012 19:23
PowerShell script to make ~\Documents more usable, hides directories and makes them accessible via a symlink in a different location.
param(
[Parameter(Position=0)]
$Item,
[Switch] $WhatIf,
[String] $AppConfig = "$env:HOMEDRIVE$env:HOMEPATH\AppConfig",
[String] $BaseDir = ".",
[Parameter(ParameterSetName="register")]
[Switch]
$Register,
@chklauser
chklauser / matrix.c
Created September 24, 2012 09:06
LU decomposition and matrix multiplication with OpenMP
/*
* matrix.c - Matrix computations that has been optimized by the students
*
* Copyright (c) 2011 Christian Klauser, All rights reserved
* Author: Christian Klauser <[email protected]>,
*
* I used comparatively simple algorithms for both LU-decomposition
* and the matrix multiplication involved in checking for equality.
* - My LU decomposition is based on Gaussian Elimination
* - No pivoting, will fail for pivots that are == 0
@chklauser
chklauser / page-rename-example.xml
Created October 3, 2012 19:36
Example of the history of a page-rename.
<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.7/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.7/ http://www.mediawiki.org/xml/export-0.7.xsd" version="0.7" xml:lang="en">
<siteinfo>
<sitename>Wikipedia</sitename>
<base>http://en.wikipedia.org/wiki/Main_Page</base>
<generator>MediaWiki 1.20wmf12</generator>
<case>first-letter</case>
<namespaces>
<namespace key="-2" case="first-letter">Media</namespace>
<namespace key="-1" case="first-letter">Special</namespace>
<namespace key="0" case="first-letter" />
#!/bin/bash
export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
export PASSPHRASE=YOU_PASSHRASE
# directories, space separated
SOURCE="/home/thomas/backup /home/thomas/bin /home/thomas/documents"
BUCKET=s3+http://mybucket
LOGFILE=/home/thomas/tmp/duplicity.log
# set email to receive a backup report
@chklauser
chklauser / .gitconfig
Created August 3, 2015 08:29
Nice git log
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
@chklauser
chklauser / XorLinkedList.cs
Created August 10, 2015 20:18
XOR linked list in pure C#
// Proof-of-concept XorLinkedList
// Mostly untested! Do not use in serious code!
// NO WARRANTIES AT ALL!
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
@chklauser
chklauser / env_template.sh
Last active November 9, 2015 16:10
Poor man's bash template
_fill_in() {
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : "\${$1}"/eg' "${1}"
}
# usage
export MY_VAR=15
_fill_in "my_file.tmpl" > "my_file"
#!/bin/bash
# Simple form
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# More correct/robust form, if you have time
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
@chklauser
chklauser / lk.bash
Created April 4, 2016 07:21
Bash lk: call `less` or `ls -l` depending on context
# Bash function that calls `less` and `ls -l` depending on whether
# the target is a file or a directory. Surprisingly pleasant to use.
function lk {
local p
if [[ $# -lt 1 ]] ; then
p='.'
else
p="$1"
fi