Skip to content

Instantly share code, notes, and snippets.

View mutaku's full-sized avatar
🌌
Latent Layer 5

Matthew Martz mutaku

🌌
Latent Layer 5
View GitHub Profile
@mutaku
mutaku / printer_jobs_strings.py
Last active December 17, 2015 09:09
Create a print job string for page range by supplying a total range of pages and an exclude list (such as graphical pages or ones simply not needed).
'''Create a print job string for page range by supplying
a total range of pages and an exclude list (such as graphical
pages or ones simply not needed).
Example:
In [1]: from printer_jobs_strings import make_print_string
In [2]: pages = range(0, 25)
In [3]: exclude = [3, 6, 7, 8, 15, 24]
In [4]: make_print_string(pages, exclude)
Out[5]: '0-2,4-5,9-14,16-23'
@mutaku
mutaku / tkwatchdog.py
Last active August 3, 2018 16:56
monitor directory for file changes
import multiprocessing
import os
import sys
import time
import Queue
import threading
from tkwindow import Report
from watchdog import WatchDog
import matplotlib.pyplot as plt
import numpy
import random
plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111)
ax.grid(True)
@mutaku
mutaku / h_index.py
Last active December 25, 2015 00:59
calculating h-indices
def h_index(pubs):
"""n-publicaions with at least n-citations"""
# sort the list of citations
pubs = sorted(pubs)
# iterate over the sorted list
for i, x in enumerate(pubs):
# number of citations including this one and greater
n = len(pubs[i:])
# if this citaiton index is greater than or equal to
# n, we have an h_index
@mutaku
mutaku / serial.sh
Created November 20, 2014 15:11
Grab all the current Serial episodes via RSS feed
wget -q -O- http://feeds.serialpodcast.org/serialpodcast | grep -o "<enclosure[ -~][^>]*" | grep -o "http://[ -~][^\"]*" | xargs wget -c
@karpathy
karpathy / min-char-rnn.py
Last active April 28, 2025 17:51
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)