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 random | |
import timeit | |
ITERATIONS = 10000 | |
COMPLEXITY = 3 | |
SIZE = 1000 | |
def filter_zero(row): |
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
--- | |
# ^^^ YAML documents must begin with the document separator "---" | |
# | |
#### Example docblock, I like to put a descriptive comment at the top of my | |
#### playbooks. | |
# | |
# Overview: Playbook to bootstrap a new host for configuration management. | |
# Applies to: production | |
# Description: | |
# Ensures that a host is configured for management with Ansible. |
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
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSjTHysykU+qPHu8MLOd60aVSkf4/dEAPGAC4xhgsfOyjgZwrRuEPddjKZbn+r70h/G25lAKMRyeC/9+3+VLQaOeQB/2LGAqzm+RIkJ1d7yJ/mQ9R3jj5KFIdNhRWtxyrL/A5el3z4P5/Ycx8BIj/SSzznFRAn1Ou4+Gw/EAFgt/wM6tqotagY8PsVWtscGHsrY59YlAFNEZa6dNJMu6zfRURFP3lATymzxIhH8CjJCZfnqgstRE1rin0RIRw/r1cjCu6sSjTWrFTtPSzT/QfzC7CPkK4ryAkV4uU+OQEUKO4yOgjwRO4mdej9GdIjDJOkaQ9BArB+iSVICt27nX5B damon@hamburger |
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
print(*(' '.join('{:>2}'.format(x * y) for x in range(1, 10)) for y in range(1, 10)), sep='\n') |
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 re | |
# This removes any leading digits, or whitespace | |
foo = re.compile(r'^[\d\s]+') | |
foo.sub('', "0123345 Hello World") # 'Hello World' | |
# This removes zeros only | |
bar = re.compile(r'^[0]+') | |
bar.sub('', "012345 Hello World") # '12345 Hello World' |
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 re | |
BARCODE_PATTERN = r""" | |
^ [\W_] * # Ignore any leading non-alphanumerics | |
([\d\s]+) # Capture any digits, or spaces | |
[\W_]*$ # Ignore any trailing non-alphanumerics | |
""" | |
BARCODE_REGEX = re.compile(BARCODE_PATTERN, re.VERBOSE) |
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 expand(cls, digits, number_system=0): | |
if len(digits) == cls.expected_length: | |
barcode = digits[1:-1] | |
number_system, checksum = digits[0], digits[-1] | |
elif len(digits) == cls.expected_length - 2: | |
barcode = digits | |
checksum = None | |
else: | |
raise ValueError("Invalid barcode length") |
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
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/", | |
"Mappings" : { | |
"RegionMap" : { | |
"eu-central-1" : { | |
"AMI" : "ami-eae5ddf7" | |
}, |
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
""" | |
Here's my sample Django settings for a project I recently did. Visit http://damonjablons.wordpress.com to see the explanation. | |
""" | |
import os | |
import socket | |
# Set DEBUG = True if on the production server | |
if socket.gethostname() == 'your.domain.com': | |
DEBUG = False |
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 django.conf import settings | |
from django.template import add_to_builtins | |
import django.template.loader | |
try: | |
for lib in settings.TEMPLATE_TAGS: | |
add_to_builtins(lib) | |
except AttributeError: | |
pass |
OlderNewer