Skip to content

Instantly share code, notes, and snippets.

View zimolzak's full-sized avatar

Andy Zimolzak zimolzak

View GitHub Profile

Keybase proof

I hereby claim:

  • I am zimolzak on github.
  • I am andrewzimolzak (https://keybase.io/andrewzimolzak) on keybase.
  • I have a public key whose fingerprint is 6A51 5CD7 8038 FCE0 E630 12B6 3C06 12CF 1FCC D9EC

To claim this, I am signing this object:

@zimolzak
zimolzak / csv2wiki.pl
Created June 13, 2016 15:01
Real dumb script to turn a CSV into MediaWiki wikitable
#!/usr/bin/perl -w
use strict;
print '{| class="wikitable sortable"' . "\n";
while(<>){
print "|-\n";
my $separator;
if ($. == 1){
$separator = "!";
}
else {
from random import randint
 
for i in range(20):
c = 10
while c > 0:
print c,
r = randint(1,7)
if r <= 4:
c -= r
elif r == 5 or r == 6:
from random import uniform
 
def next_state(start_state):
r = uniform(0,1)
if start_state == 'E':
if r > 0.3:
return 'A'
else:
return 'E'
elif start_state == 'A':
@zimolzak
zimolzak / cut.pl
Created December 29, 2016 03:01
What is the distribution of common passwords?
#!/usr/bin/perl -w
use strict;
while(<>){
chomp;
my @f = split(/\t/);
print $f[1]."\n" if not /[^[:ascii:]]/
}
# Print a user-specified number of variates from distribution I just
# made up (which is kind of like an upside down V). I like it better
# than the boring old uniform distribution and friends.
# 0.075 **
# * *
# * *
# * *
# * *
# * *
@zimolzak
zimolzak / dedup.py
Created January 2, 2017 23:09
Deduplicate MP3s and AACs
from subprocess import getoutput
import os
command_b = "find /Users/ajz/Music/iTunes/iTunes\ Media/Music"
#command_b = "find /Users/ajz/Music/iTunes/iTunes\ Media/Music/Weezer"
command_a = "find /Users/ajz/powerbook/Users/ajz/Music/iTunes/iTunes\ Music"
debug = False
########
@zimolzak
zimolzak / cardware.py
Created February 14, 2017 18:38
Construct deck of only broadway cards. Draw 3 without replacement. 6840 seqs, 12.7 bits entropy.
from random import sample
from itertools import product
 
p = product(['A', 'K', 'Q', 'J', 'T'],
['s', 'h', 'd', 'c'])
 
deck = [''.join(e) for e in p]
 
print(sample(deck, 3))
@zimolzak
zimolzak / curses_brightness.py
Last active February 22, 2017 22:26
Control Linux screen brightness using keys in a Curses terminal
#!/usr/bin/env python3
import curses
max_b = int(open('/sys/class/backlight/radeon_bl0/max_brightness', 'r').read())
min_b = 40
columns = 70
def main(stdscr):
stdscr.clear()
k = 'x'
stdscr.addstr(1, 0, 'q to quit')
library(ggplot2)
X = data.frame(d=c(0,1,2,3,4,5,6,7,8,9), segments=c(6,2,5,5,4,5,6,3,7,6), bits=c(0,1,1,2,1,2,2,3,1,2))
ggplot(X, aes(bits, segments, label=d)) + geom_path(position = position_jitter(width=0.1, height=0.1)) + geom_label(position = position_jitter(width=0.3, height=0.3))