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
@karpathy
karpathy / min-char-rnn.py
Last active November 4, 2024 09:06
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)
@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
@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
import matplotlib.pyplot as plt
import numpy
import random
plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111)
ax.grid(True)
@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
@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'
@Bpless
Bpless / shell_plus_reloader.py
Last active June 5, 2018 11:40
Shell_Plus reloader thread
class ReloaderEventHandler(FileSystemEventHandler):
"""
Listen for changes to modules within the Django project
On change, reload the module in the Python Shell
Custom logic required to reload django models.py modules
Due to the singleton AppCache, which caches model references.
For those models files, we must clear and repopulate the AppCache
"""
def __init__(self, *args, **kwargs):
@mutaku
mutaku / palindrome.cpp
Created November 15, 2012 21:23
palindromes (output stuffs here: https://gist.github.com/4219658 )
/* palindrome.cpp
* C++ implementation of palindrome.py
* (https://gist.github.com/4081368)
*
* - Matthew Martz 2012
*/
#include <iostream>
#include <string>
#include <sstream>
@mutaku
mutaku / store_credit.py
Created August 7, 2012 21:58
Google code challenge - credit
#!/usr/bin/env python
# Google Code Challenge - Credit Problem
# http://code.google.com/codejam/contest/351101/dashboard#s=p0
import itertools
import bisect
from time import time
def last(array, num):
@omarish
omarish / gist:3080200
Created July 10, 2012 00:42
Priceonomics Puzzles

Priceonomics Programming Puzzle, Summer 2012

We love solving puzzles at Priceonomics. We also like meeting people who like to solve puzzles. Here are two interesting puzzles we've faced at some point in the past months that we'd like to share with you.

If you have any questions, contact omar@priceonomics.com.


Puzzle 1: Heatwave