Skip to content

Instantly share code, notes, and snippets.

View blackrobot's full-sized avatar
🖖
coffee

Damon Jablons blackrobot

🖖
coffee
View GitHub Profile
import random
import timeit
ITERATIONS = 10000
COMPLEXITY = 3
SIZE = 1000
def filter_zero(row):
---
# ^^^ 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.
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
@blackrobot
blackrobot / multiplication_table.py
Last active August 29, 2015 14:11
Prints a multiplication table
print(*(' '.join('{:>2}'.format(x * y) for x in range(1, 10)) for y in range(1, 10)), sep='\n')
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'
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)
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")
{
"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"
},
"""
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
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