factory_boy allows you to define attributes as sequences, e.g.:
class MyFactory(factory.Factory):
id = factory.Sequence(lambda n: "ID%s" % n)
By default, the sequence type is a str
.
#!/usr/bin/env bash | |
# Shows the build id (as reported by "go list" and "go tool buildid") of a package at a given git ref. | |
COMMIT=${1?Error: supply a commit} | |
PACKAGE=${2?Error: supply a package} | |
git checkout --detach "${COMMIT}" >/dev/null 2>&1 | |
go build -o tmp "${PACKAGE}" >/dev/null 2>&1 | |
echo -n "go tool buildid: " | |
go tool buildid tmp |
#!/bin/sh | |
for url in $(cat input.txt);do curl -s -o /dev/null -w '{"url": "%{url_effective}", "status": "%{http_code}", latency": "%{time_total}"}\n' $url; done | jq -s '.' |
#!/bin/bash | |
set -e | |
# Usage: | |
# ORG=MyOrg OAUTH_TOKEN=token ./clone.sh | |
SSH_FILTER=".[] | .ssh_url" | |
REPOS=$(curl -s -H "Authorization: token ${OAUTH_TOKEN}" https://api.github.com/orgs/$ORG/repos | jq -r "$SSH_FILTER") | |
for repo in $REPOS; do |
import "github.com/cenkalti/backoff" | |
type limitedAttempts struct { | |
limit int | |
attempts int | |
strategy backoff.BackOff | |
} | |
func NewLimitedAttempts(limit int, strategy backoff.BackOff) *limitedAttempts { | |
return &limitedAttempts{limit: limit, strategy: strategy} |
browser.get('/').then(function() { | |
return browser.waitForDeferredAngular(); | |
}); |
import logging | |
import socket, ssl | |
import re | |
import boto | |
from boto.s3.connection import S3Connection, OrdinaryCallingFormat | |
from boto.https_connection import CertValidatingHTTPSConnection | |
logging.basicConfig(level=logging.WARNING) |
import StringIO | |
from selenium import webdriver | |
from PIL import Image | |
# Install instructions | |
# | |
# npm install phantomjs | |
# sudo apt-get install libjpeg-dev | |
# pip install selenium pillow |
from unittest import skipUnless | |
from alembic.config import Config | |
from alembic.script import ScriptDirectory | |
""" | |
Usage: | |
@minimum_revision_satisfied("5aa2dfb6e6a8") | |
def test_database_function(self): | |
pass |
# Store the current locale | |
default_loc = locale.getlocale() | |
# Swap to some foreign locale, e.g. German | |
locale.setlocale(locale.LC_ALL, 'de_DE') | |
# Define a new localeconv() with some overrides | |
# see http://docs.python.org/2/library/locale.html#locale.localeconv | |
def _temp_localeconv(lc=locale.localeconv()): | |
lc.update({'decimal_point': ',', 'thousands_sep': '.'}) |