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 re | |
def regex_to_bitset(r): | |
'''Convert character class into bitset. Assumes ASCII range (0<=ch<=127).''' | |
bitset = [] | |
for i in range(0, 128, 32): | |
word = 0 | |
for j in range(i, i+32): | |
if r.match(chr(j)): | |
word |= 1 << (j - i) |
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
#!/bin/sh | |
VERSION="edge" | |
PLATFORM="x86_64" | |
DESTDIR=/mnt/d/alpine | |
sync() { | |
REPO="$1" | |
echo "Synchronizing $1..." | |
rsync --verbose --archive --update --hard-links --delete --delete-after --delay-updates --timeout=600 \ |
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
#!/usr/bin/env python | |
# | |
# Displays the average line length from a directory of source files. | |
# | |
# Luke McCarthy 2018 | |
from __future__ import print_function | |
import argparse | |
import os | |
import re |
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
#if 0 | |
set -e | |
[ -z "$CC" ] && CC=$(which tcc clang gcc cc | head -1) | |
out="$(tempfile -p $(echo $(basename $0) | cut -f 1 -d '.'))" | |
$CC -pipe -x c -std=c99 -g -ftrapv -o $out "$0" | |
exec $out "$@" | |
#endif | |
#include <stdio.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
#include <assert.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
size_t varint_size(uint32_t value) { | |
return value < 0x80 ? 1 : | |
value < 0x4000 ? 2 : | |
value < 0x200000 ? 3 : | |
value < 0x10000000 ? 4 : 5; |
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
#!/usr/bin/env python3 | |
import os | |
import re | |
import sys | |
def incbin(filename): | |
with open(filename, 'rb') as f: | |
data = f.read() | |
name = os.path.splitext(os.path.basename(filename))[0] |
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
format MZ | |
entry main:start | |
use16 | |
segment main | |
start: | |
; detect EGA BIOS | |
mov ah, 0x12 | |
mov bl, 0x10 |
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
format MZ | |
entry main:start | |
use16 | |
segment main | |
start: | |
call detect_cpu | |
mov dx, strings | |
mov ds, dx |
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
format MZ | |
entry main:start | |
use16 | |
segment main | |
start: | |
call detect_i386 | |
mov dx, strings.error | |
jnc .print |
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
Get-WmiObject -Class Win32_DiskDrive | | |
Where-Object {$_.Capabilities -contains 3 -and $_.MediaType -eq "Removable Media"} | | |
Select-Object Caption, Size, SerialNumber, InterfaceType, DeviceID, Status |