Skip to content

Instantly share code, notes, and snippets.

@johntyree
johntyree / dups.py
Last active January 3, 2016 09:59
Find bit-exact duplicate files.
#!/usr/bin/env python2
# coding: utf8
# GistID: 8446782
import hashlib
import os
import sys
def get_size(path):
@johntyree
johntyree / mem.py
Created January 7, 2014 16:25
Memory profile of numpy array access
# GistID: 8301919
import numpy as np
import gc
from memory_profiler import profile
n = 30
m = 1000000
@profile
@johntyree
johntyree / scrot-shot.sh
Created January 3, 2014 19:40
Screenshot with scrot for hotkeys
#!/bin/bash
#GistID: 8245054
# By default we take a full screen shot and name it the current time
# If -s is passed as first argument, we do window/selection mode
DATETIME=$(date +%F_%T.%N | rev | cut -c 8- | rev)
OUTPUTDIR="~/Pictures/Screenshots/"
@johntyree
johntyree / soundcloud
Created January 3, 2014 03:50
Add soundcloud streams to your mpd playlist
#!/usr/bin/env python3
# coding: utf8
# GistID: 8232376
import optparse
import sys
from subprocess import check_call
from urllib.parse import urlparse, quote, urlencode
#!/usr/bin/env python
# coding: utf8
import sys
from numpy import loadtxt
from matplotlib.pyplot import matshow, show
mat = loadtxt(sys.stdin, dtype=bool, delimiter=',')
matshow(mat)
show()
// GistID: 7920541
//
//
// In this exercise you should get familiar with closures and
// implement an elementary cellular automaton (CA)
// [http://en.wikipedia.org/wiki/Elementary_cellular_automaton]. Read
// the article before proceeding. Then study closures from
// https://developer.mozilla.org/en/JavaScript/Guide/Closures and make
// sure you understand "Emulating private methods with closures" part
@johntyree
johntyree / jpp.py
Created December 10, 2013 16:01
Generic preprocessor
#!/usr/bin/env python
# coding: utf8
# GistID: 7893054
""" A generic preprocessor.
Replace `#include "<file>"` lines with file contents.
If the line starts with '//' then leave the include line in the output
for reference.
#!/usr/bin/env python3
# coding: utf-8
# GistID: 7799767
from __future__ import print_function
# import cStringIO
import itertools
import os
import re
@johntyree
johntyree / hangman.hs
Created May 1, 2013 19:22
Hangman in Haskell
module Main where
import Prelude hiding (catch)
import Control.Applicative
import Control.Exception
import Control.Monad.State
import Data.List
import System.IO
import System.Random
import Options.Applicative
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.