Skip to content

Instantly share code, notes, and snippets.

View fritschy's full-sized avatar

Marcus Borkenhagen fritschy

  • Black Forest, Germany
View GitHub Profile
@fritschy
fritschy / sort_objdump_dasm.py
Created August 31, 2011 10:53
Sort objdump -d ouput by function name (useful for text compares).
#!/usr/bin/python
import sys, re
infunction=False
currfunc=""
funclines=[]
functions={}
for line in sys.stdin:
@fritschy
fritschy / expr.cpp
Created August 31, 2011 13:59
Expression template example, "binds" an expression to a variable.
#include <iostream>
#define SHOW_EXPRESSION() std::cout << __PRETTY_FUNCTION__ << std::endl
namespace expr
{
template<typename E> float Eval(E const &e) { return e.eval(); }
float Eval(float e) { return e; }
struct val
@fritschy
fritschy / quat.hpp
Created August 31, 2011 19:37
Silly quaternion implementation based on type transformation
#include <iostream>
#include <cmath>
namespace quaternion {
namespace imaginary {
// rules for calculating quaternion imaginaries
// ij = k
// ik = j
@fritschy
fritschy / DecorateSortUniq.hs
Created September 20, 2011 08:12
sort -u for arbitrary haskell lists
module DecorateSortUniq where
import Data.List
decorateSortUniq :: Ord a => [a] -> [a]
decorateSortUniq = map snd . sortBy (\(a,_) (b,_)->compare a b) . uniq snd . sortBy (\(_,a) (_,b)->compare a b) . zip [0..]
where uniq f (x:y:xs) = if f x == f y then uniq f (x:xs) else x:uniq f (y:xs)
uniq _ (x:_) = [x]
@fritschy
fritschy / git-send-outlook-email.py
Created August 20, 2014 10:39
Submit patches using git send-email/format-patch that are compatible with an msft exchange/outlook receiver
# Marcus Fritzsch, July 2014
import os.path
import sys
import glob
from tempfile import mkdtemp
from email.parser import Parser
from email.generator import Generator
from subprocess import check_output
@fritschy
fritschy / denon.go
Last active August 29, 2015 14:17
Talking to a Denon AVR via telnet and with readline support (Tested on an AVR X-4000)
// This was hacked up by Marcus Fritzsch, @znephf
//
// Please make sure this does what you think it does, as I am not
// responsible for any damage it might cause.
//
// TODO:
// - Profiles: check what is played and fix settings accordingly
// - Setting Profiles from file
// - Browser interface through HTTP
@fritschy
fritschy / build-selfhost-cmake.zsh
Created March 23, 2015 14:09
Build clang, doing self-hosting
#! /bin/zsh
# Get llvm, clang and compiler-rt from these locations:
#INSTALL#http://llvm.org/git/llvm.git#llvm
#INSTALL#http://llvm.org/git/clang.git#llvm/tools/clang
#INSTALL#http://llvm.org/git/lldb.git#llvm/tools/lldb
#INSTALL#http://llvm.org/git/compiler-rt.git#llvm/projects/compiler-rt
if [ "$1" = "get" ] || [ "$1" = "install" ]
then
@fritschy
fritschy / install-pebble-sdk.sh
Last active August 29, 2015 14:20
Install Pebble SDK on a Debian SID x86-64 (status 2015-05-04)
#!/bin/zsh
# Install pebble SDK in ~/opt/$pebble-sdk-rootdir-name and apply some patches
# This method of installing still worked as of 20150-05-04
# Usage: $0 "$pebble-sdk-tarball"
set -e
tar -C ~/opt -xvf "$1"
tar -tf "$1" | head -n1 | read d
cd ~/opt/$d
tc=http://assets.getpebble.com.s3-website-us-east-1.amazonaws.com/sdk/arm-cs-tools-ubuntu-universal.tar.gz
sdkp=${1:h}/${tc:t}
@fritschy
fritschy / eglextension-deps.py
Created August 11, 2015 14:24
Create a graphviz digraph file from a number of EGL_*.txt files
#!/usr/bin/env python3
import sys
def main():
out = {}
for fn in sys.argv[1:]:
ext=fn.split('.',1)[0]
with open(fn) as inp:
in_deps=False
@fritschy
fritschy / lazy.lua
Created September 10, 2015 08:48
Lazy lists in lua, kinda sorta really useless
#!/usr/bin/env lua5.2
local cryield = coroutine.yield
local crwrap = coroutine.wrap
function map(f, xs)
return crwrap(function()
for v in xs do
cryield(f(v))
end