Skip to content

Instantly share code, notes, and snippets.

View msiemens's full-sized avatar

Markus Siemens msiemens

View GitHub Profile
@msiemens
msiemens / gist:5143963
Created March 12, 2013 15:40
A simple Python file caching decorator, caching the function's response till the given file has been changed.
import os
import inspect
from functools import wraps
_file_cache = {}
def cache_file(path):
def cache_is_fresh(name):
@msiemens
msiemens / multi_byte.rs
Created February 27, 2021 11:12
ISF Multi-Byte Encoding (buggy!) and Decoding in Rust
//! Multi-byte encoding/decoding
//!
//! Following the multi-byte encoding described in [\[MS-ISF\]] (sections _Multi-byte Encoding of
//! Signed Numbers_ and _Sizes of Tags and Numbers_).
//!
//! [\[MS-ISF\]]: https://docs.microsoft.com/en-us/uwp/specifications/ink-serialized-format
use itertools::Itertools;
pub(crate) fn decode(input: &[u8]) -> Vec<u64> {
@msiemens
msiemens / setup.py
Created September 5, 2013 09:50
setup.py: Load requires from requirements.txt
try:
from pip.req import parse_requirements
except ImportError:
def requirements(f):
reqs = open(f, 'r').read().splitlines()
reqs = [r for r in reqs if not r.strip().startswith('#')]
return reqs
else:
def requirements(f):
install_reqs = parse_requirements(f)
@msiemens
msiemens / README.md
Created May 14, 2017 20:18
List of German hyphenated words
@msiemens
msiemens / pre-commit.sh
Last active February 26, 2017 02:33
My git pre-commit hook
#!/bin/bash
# Git pre-commit hook
#####################
#
# - check for whitespace problems (trailing spaces, ...)
# - check for lines with 'FIXME'
# - running tests
# - running code style check (pep8) on modified files
# - designed for Windows, for Linux replace `> NUL` with `> /dev/null`
@msiemens
msiemens / pre-commit-eslint
Last active October 15, 2016 13:49 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$" | grep -Ev ".min.js|/lib/|/vendor/")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
MOV [5] 0
JEQ 90 [5] 100
APRINT 46
MOV [8] 0
RANDOM [6]
MOV [2] [6]
MOV [3] 2
MOV [1] 25
JMP 125
MOV [6] [0]
@msiemens
msiemens / gist:5363828
Last active December 16, 2015 02:39
Python Sphinx Inline Docs
def func(arg1, arg2):
"""
Summary.
Long explanation...
:param arg1: Descr for arg1
:type arg1: arg1 type
:param arg2: Descr for arg2
@msiemens
msiemens / gist:5362936
Last active December 16, 2015 02:29
Nosetests Assertion Methods
assertion_methods = [
'assert_almost_equal(s)'
'assert_dict_contains_subset',
'assert_dict_equal',
'assert_equal(s)',
'assert_false',
'assert_greater',
'assert_greater_equal',
'assert_in',
'assert_is',
@msiemens
msiemens / style.css
Last active December 12, 2015 12:09
body{
color:#444;
font-family:Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman',
"Hiragino Sans GB", "STXihei", "微软雅黑", serif;
font-size:12px;
line-height:1.5em;
background:#fefefe;
width: 45em;
margin: 10px auto;
padding: 1em;