This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* TO COMPILE: */ | |
/* pandoc -s --toc --css pandoc.css <IN>.md -o <OUT>.html */ | |
/* NOTE: */ | |
/* include % <TITLE> as first line of md file to set html title */ | |
body { | |
font-size: 12px; | |
margin: auto; | |
max-width: 80ch; | |
letter-spacing: .05em; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" == "prod" ]; then | |
printf '\033]11;#331C1F\007' # red | |
elif [ "$1" == "dev" ]; then | |
printf '\033]11;#192436\007' # blue | |
elif [ "$1" == "other" ]; then | |
printf '\033]11;#253320\007' # green | |
else | |
printf '\033]11;#282c34\007' # black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from collections import Counter | |
from PIL import Image | |
import math, os, sys | |
def create_image(filename): | |
# build digram | |
digram = Counter() | |
with open(filename, 'rb') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from collections import * | |
from random import random | |
def train_char_lm(fname, order=4): | |
with open(fname, 'r') as f: | |
data = f.read() | |
lm = defaultdict(Counter) | |
pad = '~' * order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#define TIMING(func) {\ | |
int start=clock();\ | |
func;\ | |
int diff = clock() - start;\ | |
int msec = diff * 1000 / CLOCKS_PER_SEC;\ | |
printf("ms: %d\n", msec);\ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
# define D if(1) | |
#else | |
# define D if(0) | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
from functools import wraps | |
__all__ = ['timeout', 'TimeoutError'] | |
class TimeoutError(Exception): pass | |
# IMPORTANT: this is not thread-safe | |
def timeout(seconds, error_message='Function call timed out'): | |
def _handle_timeout(signum, frame): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# +------------------------------------------------------------------------------+ | |
# | HOW TO USE: from verbose import Log | | |
# +=================================== Basics ===================================+ | |
# | <Inputs> | | |
# | msg : used as the main message to output (this is the only required field) | | |
# | tag : used to conceptually group messages or add string identifier | | |
# | | | |
# | <Functions> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if sys.version[0] == '2': | |
from Queue import Queue | |
else: | |
from queue import Queue | |
from threading import Thread | |
class asynchronous(object): | |
def __init__(self, func): | |
self.func = func |