Skip to content

Instantly share code, notes, and snippets.

View bsmithyman's full-sized avatar
📎
"It looks like you're writing a distributed web app!"

Brendan Smithyman bsmithyman

📎
"It looks like you're writing a distributed web app!"
View GitHub Profile
@bsmithyman
bsmithyman / keybase.md
Created May 7, 2017 23:30
Verification post for Keybase

Keybase proof

I hereby claim:

  • I am bsmithyman on github.
  • I am bsmithyman (https://keybase.io/bsmithyman) on keybase.
  • I have a public key ASBOa1GAD4sXYNqt3C8cl8KaXBx0A4erRUGsaYDCE_3j0Ao

To claim this, I am signing this object:

@bsmithyman
bsmithyman / resumable.py
Created October 5, 2016 21:44
Generate a resumable upload URL for Google Cloud Storage
import json
import os
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
GCP_CREDENTIALS_FILE = os.getenv('GCP_CREDENTIALS_FILE', 'client-secret.json')
GCS_UPLOAD_URL_PATTERN = 'https://www.googleapis.com/upload/storage'+ \
'/v1/b/{bucket}/o?uploadType=resumable'
def get_upload_url(bucket, filename, content_length, content_type='application/octet-stream'):
@bsmithyman
bsmithyman / graph_stack.py
Last active May 4, 2016 19:42
Generate a call graph for the enclosed context
import contextlib
import os.path
from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutput
@contextlib.contextmanager
def graph_stack(filename):
'Generate a call graph for the enclosed context'
go = GraphvizOutput(output_file=filename)
go.output_type = os.path.splitext(filename)[-1][1:]
@bsmithyman
bsmithyman / style.css
Created February 10, 2016 01:33
vnstat PHP frontend EdgeOS theme
body
{
background-color: #3f3f3f;
margin: 8px;
padding: 0;
}
#content
{
width: 898px;
class Blorgle(object):
@property
def incompatible(self):
import inspect
frame = inspect.currentframe()
print('Current')
print(frame.f_locals.get('self', None))
print('Previous')
print(frame.f_back.f_locals.get('self', None))
print('2Prev')
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm 4.2.0 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_ARM_HAS_SG_CHAIN=y
CONFIG_MIGHT_HAVE_PCI=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
CONFIG_HAVE_PROC_CPU=y
CONFIG_STACKTRACE_SUPPORT=y
@bsmithyman
bsmithyman / gb.py
Last active September 19, 2015 02:10
def GB(tag = None):
import sys
if not hasattr(GB, 'badgercount'):
GB.badgercount = 0
sys.stdout.write('Guard badger: %03d is named %s'%(GB.badgercount, 'Stanley' if not tag else tag))
sys.stdout.flush()
GB.badgercount += 1
@bsmithyman
bsmithyman / vnstati.sh
Last active September 14, 2015 17:00
Crontab entry for vnstati to email
0 7 1 * * (vnstati -m -i eth1 -o /tmp/vnstati.png && uuencode /tmp/vnstati.png /tmp/vnstati.png && vnstati -d -i eth1 -o /tmp/vnstati.png && uuencode /tmp/vnstati.png /tmp/vnstati.png) | mailx -s "Network Usage" brendan@bitsmithy.net
#!/bin/bash
cat << END
<html>
<body>
<pre style="font-family: consolas,monospace;font-size:8pt">
END
cat -
@bsmithyman
bsmithyman / LICENSE
Last active July 28, 2016 13:51
Pure Python implementation of SEG-Y file input; originally from https://github.com/bsmithyman/pygeo.
Licensed under GNU Lesser General Public License
Originally part of 'pygeo' (also by Brendan Smithyman).
https://www.gnu.org/licenses/lgpl.html