Skip to content

Instantly share code, notes, and snippets.

Avatar

Markus Siemens msiemens

View GitHub Profile
@msiemens
msiemens / multi_byte.rs
Created Feb 27, 2021
ISF Multi-Byte Encoding (buggy!) and Decoding in Rust
View multi_byte.rs
//! 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 / README.md
Created May 14, 2017
List of German hyphenated words
View README.md
@msiemens
msiemens / pre-commit-eslint
Last active Oct 15, 2016 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
View pre-commit-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
@msiemens
msiemens / helpers.py
Last active Aug 29, 2015
My helpers.py file
View helpers.py
"""
My compilation of small helper functions.
"""
import logging
import os
import threading
import traceback
import sys
from logging.handlers import SMTPHandler
@msiemens
msiemens / types.c
Created May 24, 2014
Fundamental C Types
View types.c
int main(void) {
char v_char;
unsigned char v_uchar;
short v_short;
unsigned short v_ushort;
int v_int;
unsigned int v_uint;
long v_long;
unsigned long v_ulong;
long long v_longlong;
View gist:6672efc032769758423b
def fourier_series(f, frange, t, t_0):
k = symbols('k', integer=True, positive=True, zero=False)
a_k = 2/t_0*(integrate(f * cos(2*pi/t_0*k*t), [t, frange[0], frange[1]]))
a_k = [a_k.subs(k, i) for i in range(1, 10)]
b_k = 2/t_0*(integrate(f * sin(2*pi/t_0*k*t), [t, -t_0/2, t_0/2]))
b_k = [b_k.subs(k, i) for i in range(1, 10)]
# Amplitude
@msiemens
msiemens / setup.py
Created Sep 5, 2013
setup.py: Load requires from requirements.txt
View setup.py
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)
View pi-preprocessed.asm
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 / pre-commit.sh
Last active Feb 26, 2017
My git pre-commit hook
View pre-commit.sh
#!/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 / gist:5363828
Last active Dec 16, 2015
Python Sphinx Inline Docs
View gist:5363828
def func(arg1, arg2):
"""
Summary.
Long explanation...
:param arg1: Descr for arg1
:type arg1: arg1 type
:param arg2: Descr for arg2