Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import cv2
import numpy as np
import wave
import struct
import sys
# usage instructions:
# ./image2spectrogram.py input.png
@mwgamera
mwgamera / tbraille.bdf.pl
Last active August 29, 2015 14:07
14-px Braille bitmap font compatible with Terminus.
#!/usr/bin/env perl
# 14-px Braille bitmap font compatible with Terminus.
# klg, Oct 2014
use strict;
use List::MoreUtils 'pairwise';
use constant XLFD => '-klg-TBraille-Medium-R-Normal--14-140-72-72-C-80-ISO10646-1';
use constant BBX => (8, 14, 0, -2);
my %properties = do {
#!/usr/bin/env perl
# Change modification time stored in GZIP file.
# klg, Oct 2014
use strict;
use open IN => ':bytes';
use Time::Local;
use constant GZIP_ID => 0x8b1f;
use constant FLG_FHCRC => (1 << 1);
#!/usr/bin/env perl
# Extract deflated first member from PKWARE ZIP as GZIP.
# klg, Feb, Oct 2014
use strict;
use constant {
ZIP_FILE => 0x04034b50,
GZIP_MAGIC => 0x8b1f,
CM_DEFLATE => 8,
};
#!/usr/bin/env perl
# Compare Debian versions; faster than Dpkg::Version. Probably pointless.
# klg, Nov 2014
use strict;
do {
my $ver_split = sub {
shift =~ m/^
(?|([0-9]+):([0-9a-z.+:~-]+)-([0-9a-z+.~]+)
#!/bin/sh
# List packages not available in remote repositories.
# klg, Dec 2014
set -e
if [ -n "$1" -a '/-a' != "/$1" ]
then
echo >&2 "Usage: $0 [-a]"
exit 1
fi
// — ⁂ —
hr {
height: 0; width: 100%;
margin: $line-height 0;
border: 0; padding: 0;
color: inherit; // Firefox
text-align: center;
line-height: 0;
cursor: default;
overflow: visible; // IE
#!/usr/bin/env perl
# Examine DEFLATE streams.
# klg, Jan 2015
use strict;
use open IN => ':bytes';
#### Containers ###############################################################
sub extract_zlib { # RFC 1950
@mwgamera
mwgamera / pkix.go
Created February 26, 2015 09:55
I'm considering rewriting vanity ID generator for Chrome extensions <https://gist.github.com/mwgamera/9774270> in Go as an exercise to learn Go.
package main
// -- From RFC 3280 PKIX:
//
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier,
// subjectPublicKey BIT STRING }
//
// AlgorithmIdentifier ::= SEQUENCE {
// algorithm OBJECT IDENTIFIER,
%!PS
% klg, Mar 2015
%%BoundingBox: 0 123 595 718
/primes { % n primes array
3 sub 2 idiv array
% sieve
dup length 1 sub
0 1 3 -1 roll {
2 copy get