Skip to content

Instantly share code, notes, and snippets.

🖖
coffee

Damon Jablons blackrobot

🖖
coffee
Block or report user

Report or block blackrobot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View attila_vs_damon.py
import random
import timeit
ITERATIONS = 10000
COMPLEXITY = 3
SIZE = 1000
def filter_zero(row):
View pedantically_commented_playbook.yml
---
# ^^^ 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.
View id_rsa.pub
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 Aug 29, 2015
Prints a multiplication table
View multiplication_table.py
print(*(' '.join('{:>2}'.format(x * y) for x in range(1, 10)) for y in range(1, 10)), sep='\n')
View remove_zeros.py
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'
View barcode_regex.py
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)
View upce.py
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")
View aws-cloudformation.coreos-stable-hvm.json
{
"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"
},
View The Perfect Django Settings File
"""
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
View __init__.py
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
You can’t perform that action at this time.