Skip to content

Instantly share code, notes, and snippets.

View samuelcolvin's full-sized avatar

Samuel Colvin samuelcolvin

View GitHub Profile
HISTSIZE=10000
HISTFILESIZE=200000
export PS1='\W || '
alias gs="git status --short --branch"
alias gl="git log2"
alias gb="git branch2"
alias gm="git checkout master"
alias gp="git pull"
alias cl="clean_terminal.sh"
alias oman="helpmanual.py"
[user]
email = <your email>
name = <your name>
[core]
editor = vim
[push]
default = simple
[alias]
pushf = push --force-with-lease
commend = commit --amend --no-edit
Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1
"""
Launch ipython with a custom namespace and configuration
"""
from IPython import start_ipython
from IPython.terminal.ipapp import load_default_config
c = load_default_config()
c.TerminalIPythonApp.display_banner = False
c.TerminalInteractiveShell.confirm_exit = False
@samuelcolvin
samuelcolvin / tc_webhook_auth.py
Created January 19, 2017 12:19
Demonstrating of authenticating a webhook from TutorCruncher.
"""
Demonstrating of authenticating a webhook from TutorCruncher.
This isn't build with any web framework in particular but demonstrates the idea in generic python 3.
"""
import hashlib
import hmac
import json
SHARED_SECRET = b'this is also the api key'
@samuelcolvin
samuelcolvin / benchmark.cfg
Created February 3, 2017 20:41
config file suitable for running FrameworkBenchmarks in vagrant
[Defaults]
# Available Keys:
os=linux
server_host=TFB-server
client_host=TFB-client
client_identity_file=/home/vagrant/.ssh/id_rsa
client_user=vagrant
database_host=TFB-database
database_identity_file=/home/vagrant/.ssh/id_rsa
database_os=linux
@samuelcolvin
samuelcolvin / settings.yml
Created February 4, 2017 12:41
setup and settings for running aiohttp benchmarks.
dev:
py_file: app/main.py
@samuelcolvin
samuelcolvin / gist:9f81e123e4438cc591659ae87926cb40
Created February 11, 2017 14:49
json info about a pypi package
https://pypi.python.org/pypi/aiohttp/json
@samuelcolvin
samuelcolvin / dns_server.py
Last active November 4, 2024 02:17
requires python 3.5+ and dnslib, see https://github.com/samuelcolvin/dnserver for full/better implementation
from datetime import datetime
from time import sleep
from dnslib import DNSLabel, QTYPE, RD, RR
from dnslib import A, AAAA, CNAME, MX, NS, SOA, TXT
from dnslib.server import DNSServer
EPOCH = datetime(1970, 1, 1)
SERIAL = int((datetime.utcnow() - EPOCH).total_seconds())
FROM alpine:3.5
LABEL maintainer "[email protected]"
RUN apk --update --no-cache add bash drill && rm -rf /var/cache/apk/*
WORKDIR /home/root
CMD ["./run.sh"]