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 | |
import random | |
import nltk | |
import os | |
import pickle | |
from nltk.corpus import brown | |
import click |
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
# -*- coding: utf-8 -*- | |
try: | |
from pipes import quote | |
except ImportError: | |
from shlex import quote | |
import json | |
import os | |
import vim |
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/zsh | |
TARGET=$(tmux new-window -P) | |
tmux split-window -t $TARGET -hb -c "#{pane_current_path}" | |
tmux split-window -t $TARGET -v -c "#{pane_current_path}" | |
tmux resize-pane -t $TARGET -R 15 | |
tmux select-pane -t $TARGET -L |
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 math | |
def short_filesize(size): | |
labels = ['B', 'KB', 'MB', 'GB', 'TB'] | |
index = min(int(math.floor(math.log(size, 1024))), len(labels)) | |
short = size / 1024**index | |
return '%.2f%s' % (short, labels[index]) |
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
from flask import json | |
class ExJSONEncoder(json.JSONEncoder): | |
'''Extended JSON encoder for more type support''' | |
def default(self, o): | |
if isinstance(o, set): | |
return list(o) | |
elif isinstance(o, arrow.Arrow): | |
o = o.datetime |
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 json | |
from sqlalchemy.inspection import inspect | |
class AlchemyEncoder(json.JSONEncoder): | |
'''JSON encoder for SQLAlchemy models, using inspection API''' | |
def __init__(self, skipkeys=False, ensure_ascii=True, | |
check_circular=True, allow_nan=True, sort_keys=False, | |
indent=None, separators=None, default=None, relations=False, | |
**kw): |