Skip to content

Instantly share code, notes, and snippets.

@twik
twik / Makefile
Created November 29, 2017 06:53 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@twik
twik / python_colors.py
Created March 23, 2015 04:54
python_colors.py
#!/usr/bin/env python
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
from __future__ import with_statement
import itertools
import functools
import sys
def download_files(keylist):
return [key.get_contents_to_filename('%s/%s' % (TEMP_DIR, key.name))
for key in keylist]
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
These are snippets of py.test in action, used in a talk given at
PyCon AU 2012 in Hobart, Tasmania. They are all relevant for
py.test 2.2 except where specified. Where taken from open source
projects I have listed a URL, some examples are from the py.test
documentation, some are from my workplace.
Apart from things called test_*, these functions should probably
be in your conftest.py, although they can generally start life in
your test files.
# install sysbench
$ apt-get install sysbench
# CPU benchmark, 1 thread
$ sysbench --test=cpu --cpu-max-prime=20000 run
# CPU benchmark, 64 threads
$ sysbench --test=cpu --cpu-max-prime=20000 --num-threads=64 run
# Disk benchmark, random read. See .fio files in this gist
@twik
twik / gist:7995720
Created December 16, 2013 22:38
Retina CSS Button
font-family: Helvetica, Arial, Verdana, sans-serif;
font-family: "helvetica neue",arial,sans-serif
font-family: "Myriad Pro", arial, sans-serif
font-family: Helvetica, Gill, sans-serif;
font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace
media="screen"
.bouncey {
@twik
twik / gist:7993600
Created December 16, 2013 20:15
How to install Consolas on Mac OSX
#!/bin/bash
# makes the rendering of the font a bit thinner
defaults -currentHost write -globalDomain AppleFontSmoothing -int 0
brew install cabextract
TEMP_DIR=`mktemp -dt "$0"` && cd $TEMP_DIR
curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
cabextract PowerPointViewer.exe
@twik
twik / gist:7916172
Created December 11, 2013 18:49
List the contents of folders recursively, sorted by modification time.
#! /usr/bin/env python
# See http://preshing.com/20130115/view-your-filesystem-history-using-python
import optparse
import os
import fnmatch
import time
# Parse options
parser = optparse.OptionParser(usage='Usage: %prog [options] path [path2 ...]')
parser.add_option('-g', action='store', type='long', dest='secs', default=10,
@twik
twik / gist:6519144
Created September 11, 2013 03:47
Backup all photos from Messages.app
#! /bin/sh
mkdir $HOME/Pictures/backup_Messages_photos/
find $HOME/Library/Messages/Attachments -iname \*.jp* | parallel -X cp -v -p {} $HOME/Pictures/backup_Messages_photos/