Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block mooware

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mooware /
Last active Jul 18, 2019
Simple application to play streams through HTML5 video
# uses as web framework, livestreamer for getting the stream URL
# and hls.js to play the HLS stream in an HTML5 video tag
from bottle import *
from livestreamer import Livestreamer
import sys, re, json
if sys.version_info.major >= 3:
from urllib.request import urlopen
def u(s):
mooware / gnu-libc-print-stacktrace.c
Last active Jul 12, 2019
Print a stacktrace on Linux with GNU libc
View gnu-libc-print-stacktrace.c
// this code fragment shows how to print a stack trace (to stderr)
// on Linux using the functions provided by the GNU libc
#include <execinfo.h>
#define MAX_STACK_LEVELS = 50;
// helper-function to print the current stack trace
void print_stacktrace()
mooware /
Last active Dec 1, 2018
Script for the Pi Hut 3D Xmas Tree
from gpiozero import LEDBoard
from time import sleep
import random
tree = LEDBoard(*range(2, 28), pwm=True)
# first led is the top one in the star
tree[0].value = 0.6
leds = range(1, len(tree))
mooware / ld-preload-intercept-method.cpp
Last active Nov 26, 2018
Intercept C++ methods with LD_PRELOAD
View ld-preload-intercept-method.cpp
// this file is an example of how to intercept a C++ method by using the
// LD_PRELOAD environment variable of the GNU dynamic linker.
// it works like this:
// 1) define a method that will have the same symbol as the intercepted
// method when compiled. For example, the method Foo::getValue()
// defined here has the mangled symbol "_ZNK3Foo8getValueEv".
// tools like nm, objdump or readelf can display the symbols of
// binaries.
mooware /
Last active Nov 10, 2018
Colored log output for Python logging framework. Works on Windows, Linux, and probably Mac as well.
# colored stream handler for python logging framework (use the ColorStreamHandler class).
# based on:
# how to use:
# i used a dict-based logging configuration, not sure what else would work.
# import logging, logging.config, colorstreamhandler
mooware /
Created Oct 13, 2017
Colorization for MSVC warnings and errors
import sys, re
COMPILE_PATTERN = re.compile(r'^.+\(\d+\) ?: (fatal )?(error|warning|note)( C\d+)?: .+$')
LINK_PATTERN = re.compile(r'^.+ : (fatal )?(error|warning) LNK\d+: .+$')
OTHER_PATTERN = re.compile(r'^.+ : (general |Command line )?(error|warning) \w+ ?: .+$')
class WinColorStream:
# wincon.h
mooware / snake.ino
Created Jun 30, 2017
Snake for Arduino on a LED matrix
View snake.ino
// snake on a MAX7219 led matrix
// NOTE: assuming the chip and pins are on the left side of the led matrix,
// row = 0, col = 0 is at the upper left corner
#include <LedControl.h>
// we're using a membrane keypad as controller
#include <Keypad.h>
mooware / tiny_string.h
Created Sep 6, 2016
An experimental "very short string optimization"
View tiny_string.h
// a fun little experiment i came up with:
// similar to the classic "short string optimization", we could actually use
// the bytes of the pointer itself as the short string buffer.
// a "tagged pointer" is used to distinguish between the internal buffer
// and a heap-allocated string.
#include <cassert>
#include <cstdint>
#include <cstring>
mooware / cdb-show-dump.cmd
Last active Sep 5, 2016
print lots of windows minidump information with CDB
View cdb-show-dump.cmd
@echo off
:: used cdb commands:
:: !sym noisy -> prints verbose output when searching PDBs
:: .symopt+0x40 -> accept mismatching PDBs
:: .lines -e -> enable source file and line information
:: .kframes 100 -> set max number of display stack frames to 0x100
:: lmv -> list all loaded modules with version information
:: | -> show process status
:: !peb -> show process environment block (command line arguments, environment variables)
mooware / measure.cpp
Created Mar 3, 2016
Similar to the "time" or "timeit" commands, for Windows.
View measure.cpp
#include <Windows.h>
#include <Psapi.h>
#include <stdio.h>
#include <stdint.h>
uint64_t fileTimeToUsec(const FILETIME &ft)
return ((uint64_t(ft.dwHighDateTime) << 32) | ft.dwLowDateTime) / 10;
You can’t perform that action at this time.