Skip to content

Instantly share code, notes, and snippets.

Avatar

Hector Martin marcan

View GitHub Profile
View deepduck.sc
// Get the sample here: https://mrcn.st/t/a_duck.wav
// This is what it sounds like: https://soundcloud.com/marcan42/deep-duck
s = Server.local;
"SC_JACK_DEFAULT_OUTPUTS".setenv("system:playback_1,system:playback_2");
s.waitForBoot({
b = Buffer.read(s,"a_duck.wav");
@marcan
marcan / flipvideo.py
Created Dec 30, 2015
Video player for the 32c3 flip-dot display
View flipvideo.py
#!/usr/bin/python2
import sys, ffms, time, socket
import numpy as np
source_file = sys.argv[1]
# Output one out of every N frames
framedrop = 18
# Input video FPS (hardcoded)
fps = 30
@marcan
marcan / decimate264.py
Created Sep 12, 2017
Two h.264 framerates for the price of one
View decimate264.py
#!/usr/bin/python3
import sys
KEYINT = 30
# Encode your input like this (example):
# x264 --crf 20 --keyint 30 --min-keyint 30 --bframes 1 --no-b-adapt <input> -o <output.h264>
# Produces display order IBPBPBP...BPBPP|IBPBPBP...BPBPP|...
# Decoding (file) order IPBPBPB...PBPBP|IPBPBPB...PBPBP|...
View roca_proof_of_equivalence.py
#!/usr/bin/python
import detect
# Original constants
primes = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167]
prints = [6, 30, 126, 1026, 5658, 107286, 199410, 8388606, 536870910, 2147483646, 67109890, 2199023255550,
8796093022206, 140737488355326, 5310023542746834, 576460752303423486, 1455791217086302986,
147573952589676412926, 20052041432995567486, 6041388139249378920330, 207530445072488465666,
View pyasm.py
#!/usr/bin/env python3
import os, tempfile, shutil, subprocess, ctypes
class BaseAsmFunc(object):
def __init__(self, sfunc):
self.source = sfunc.__doc__
self._tmp = tempfile.mkdtemp() + os.sep
self.compile(self.source)
def compile(self, source):
@marcan
marcan / vortex_patch.py
Created Dec 22, 2018
Alesis Vortex Wireless 2 patch to send MIDI messages when pressing the ribbon bank buttons
View vortex_patch.py
from asm import *
blob = open("image.bin", "rb").read()
start_addr = 0x08003000
patch_start = start_addr + len(blob)
assert patch_start % 4 == 0
@marcan
marcan / asm.py
Created Dec 22, 2018
Python module to assemble snippets of code
View asm.py
#!/usr/bin/env python
import os, tempfile, shutil, subprocess
class AsmException(Exception):
pass
class BaseAsm(object):
def __init__(self, source, addr = 0):
self.source = source
self._tmp = tempfile.mkdtemp() + os.sep
View ntfs_dump_mft.py
#!/usr/bin/python
import struct, sys
mfts = """
c00004f0
2067334f0
114e7d24f0
26496944f0
26f39174f0
@marcan
marcan / glibc-2.29-reiwa.patch
Created Apr 1, 2019
glibc-2.29 patch to add the Reiwa (令和) era
View glibc-2.29-reiwa.patch
--- glibc-2.29/localedata/locales/ja_JP.old 2019-04-01 17:26:52.808154026 +0900
+++ glibc-2.29/localedata/locales/ja_JP 2019-04-01 17:38:48.872822551 +0900
@@ -14946,7 +14946,9 @@
t_fmt_ampm "%p%I<U6642>%M<U5206>%S<U79D2>"
-era "+:2:1990//01//01:+*:<U5E73><U6210>:%EC%Ey<U5E74>";/
+era "+:2:2020//01//01:+*:<U4EE4><U548C>:%EC%Ey<U5E74>";/
+ "+:1:2019//05//01:2019//12//31:<U4EE4><U548C>:%EC<U5143><U5E74>";/
+ "+:2:1990//01//01:2019//04//30:<U5E73><U6210>:%EC%Ey<U5E74>";/