This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
int main() | |
{ | |
HMODULE hMod = LoadLibrary("ntdll.dll"); | |
char buf[1024]; | |
DWORD id = 0xc0000005; // code for access violation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
FOREGROUND_BLACK = 0x0000 | |
FOREGROUND_BLUE = 0x0001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# uses bottle.py 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
import sqlite3 | |
import urllib.request | |
def main(): | |
db = sqlite3.connect(os.path.join('Data', 'flashpoint.sqlite')) | |
cur = db.execute("SELECT launchCommand FROM game WHERE launchCommand LIKE '%games2jolly%'") | |
urls = [s for (s,) in cur.fetchall()] | |
for index, url in enumerate(urls): | |
print('{}/{} {}'.format(index + 1, len(urls), url)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import * | |
from urllib.request import urlopen | |
import json | |
import re | |
DEFAULT_HOSTS = ['multitwitch.tv', 'multistre.am', 'kadgar.net/live'] | |
SRL_API = "https://api.speedrunslive.com/races/" | |
SANITY_RE = re.compile('[0-9a-z]+') | |
RACE_STATE_COMPLETE = 4 # from the SRL API |