Skip to content

Instantly share code, notes, and snippets.

View wolfgangmeyers's full-sized avatar

Wolfgang Meyers wolfgangmeyers

  • AiBrush
  • Washington State, USA
View GitHub Profile
def sex(partners):
for p in partners:
assert p is not Nun
@wolfgangmeyers
wolfgangmeyers / prime sieve
Created August 23, 2013 01:46
prime sieve
import random
sieve_scan_top = 0
sieve = {}
def generate_sieve(top):
global sieve_scan_top
global sieve
if top > sieve_scan_top:
sieve_scan_top = top
@wolfgangmeyers
wolfgangmeyers / cachebuster.py
Created February 1, 2016 00:07
Simple python script to add a query string to all css / js files using a unix timestamp to force refresh of static assets.
#!/usr/bin/env python
import time
def cachebust_script_src(line):
src_i = line.find("src=")
begin_src = src_i + 5
end_src = line.find("\"", begin_src)
src_contents = line[begin_src:end_src]
parts = src_contents.split("?")
base_src = parts[0]
@wolfgangmeyers
wolfgangmeyers / workstation-rdp-tunnel.sh
Created August 10, 2016 16:18
SSH tunnel templates
# SSH tunnel for RDP access
ssh -i <key> -f -N -L3389:localhost:3389 <user>@<host>
@wolfgangmeyers
wolfgangmeyers / gist:9566680d26d8193d2b335ca10a10085a
Created March 23, 2017 13:17
Use sublime text from the command line on linux
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
@wolfgangmeyers
wolfgangmeyers / watcher.py
Created April 21, 2017 16:22
Dead simple process watcher in python. Restarts a process if and only if it dies with a non-zero exit code. Shuts down if process exits with zero.
#!/usr/bin/env python
import sys
import os
# Dead simple process watcher in python.
# Restarts a process if and only if it dies with a non-zero exit code.
# Shuts down if process exits with zero.
if __name__ == "__main__":
@wolfgangmeyers
wolfgangmeyers / README.md
Last active May 11, 2017 15:27
Sort interface boilerplate for golang in sublime text
@wolfgangmeyers
wolfgangmeyers / README.md
Last active May 11, 2017 15:28
Implement a sortable type in go - visual studio code snippet
@wolfgangmeyers
wolfgangmeyers / retries.go
Created June 1, 2017 18:17
Golang WithRetries wrapper
package retries
import "time"
// WithRetries will continue to attempt an operation
// up to the specified number of retries with an exponential
// backoff. If the operation is still unsuccessful
// after all retries are exhausted (operation returns an error),
// that error is returned.
func WithRetries(retries int, operation func() error) error {
@wolfgangmeyers
wolfgangmeyers / gist:7441fa146030f6929dd0
Last active July 15, 2018 01:11
Run an ansible playbook from the python api
# borrowed from https://groups.google.com/forum/#!topic/ansible-project/V1PoNJcXV_w
import ansible.runner
import ansible.playbook
from ansible import callbacks
from ansible import utils
stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)