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 /
Created Oct 23, 2019
Python script to monitor the Windows registry and ensure that Outlook email encryption by default stays off
import ctypes, ctypes.wintypes
advapi32 = ctypes.windll.advapi32
# LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
RegOpenKeyExA = advapi32.RegOpenKeyExA
RegOpenKeyExA.argtypes = (ctypes.wintypes.HKEY, ctypes.wintypes.LPCSTR, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD, ctypes.wintypes.PHKEY)
# LSTATUS RegCloseKey(HKEY hKey)
RegCloseKey = advapi32.RegCloseKey
mooware / constexpr-char-lookup-table.cpp
Created Sep 28, 2019
Constexpr generation of character lookup tables
View constexpr-char-lookup-table.cpp
// generate character-based static lookup tables
// that can be used for character classification,
// e.g. like in cctype functions (isdigit, isalpha ...)
struct CharLookupTable
bool data[256];
template <unsigned int N>
constexpr CharLookupTable(const char (&str)[N])
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 /
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 /
Last active Oct 9, 2019
Simple application to play streams through HTML5 video
# uses as web framework, streamlink for getting the stream URL
# and hls.js to play the HLS stream in an HTML5 video tag
from bottle import *
from streamlink import Streamlink
from urllib.request import urlopen, Request
import sys, re, json
def u(s):
if isinstance(s, str):
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 / 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;
mooware / print-exception-text.cpp
Created Feb 12, 2016
An example program to show that FormatMessage() cannot properly return the text for an exception code.
View print-exception-text.cpp
#include <windows.h>
#include <stdio.h>
int main()
HMODULE hMod = LoadLibrary("ntdll.dll");
char buf[1024];
DWORD id = 0xc0000005; // code for access violation
mooware / changeres.cpp
Last active Feb 14, 2016
Simple program to change the display resolution on Windows
View changeres.cpp
// prebuilt for VC14/VS2015 here:
#include <iostream>
#include <sstream>
#include <Windows.h>
int main(int argc, char **argv)
bool reset = false;
You can’t perform that action at this time.