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
def human_time(s): | |
""" | |
Given a time interval in seconds, return it pretty-printed. | |
>>> human_time(3.234) | |
'3.2s' | |
>>> human_time(91) | |
'1m 31s' | |
>>> human_time(3691) | |
'1h 1m' |
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
def human_size(s): | |
""" | |
Given a size interval in seconds, return it pretty-printed. | |
>>> human_size(875) | |
'875b' | |
>>> human_size(3037) | |
'3.0Kb' | |
>>> human_size(3691234) | |
'3.7Mb' |
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 python | |
# -*- coding: utf-8 -*- | |
# | |
# take.py | |
# bin | |
# | |
# Created by Lars Yencken on 2011-09-30. | |
# Copyright 2011 Lars Yencken. All rights reserved. | |
# |
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 python | |
# -*- coding: utf-8 -*- | |
# | |
# flakey_server.py | |
# | |
# Created by Lars Yencken on 2011-10-12. | |
# | |
""" | |
A web server which fails randomly and occasionally. |
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/bash | |
# | |
# highlight | |
# | |
# Highlight matching lines in the input. Like a less aggressive grep. | |
# | |
RED=$(echo -e '\033[31m') | |
NORMAL=$(echo -e '\033[00m') |
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
def a_star_search(loc, dest, ants): | |
def cost_f(path): | |
return len(path) + ants.distance(path[-1], dest) | |
initial_path = (loc,) | |
frontier = [(cost_f(initial_path), initial_path)] | |
while frontier: | |
cost, path = frontier.pop() |
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
100 | |
101 | |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | |
300 |
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
# | |
# stopwords.txt | |
# | |
# Freely available stopword list, balancing coverage and size. | |
# | |
# From http://www.lextek.com/manuals/onix/stopwords1.html | |
a | |
about | |
above | |
across |
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
cat examples | sort | uniq -c | sort -nr | head -n 50 |
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 collections import defaultdict | |
def rabbit_hole_dict(): | |
"Infinitely nested lazy dictionary." | |
return defaultdict(rabbit_hole_dict) |
OlderNewer