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 / cdSame.py
Created January 29, 2015 16:50
Change all IPython parallel workers to a common directory under $HOME
def cdSame(profile=None):
import os
from IPython.parallel import Client
if profile:
rc = Client(profile=profile)
else:
rc = Client()
dview = rc[:]
@bsmithyman
bsmithyman / KaiserWindowedSinc.py
Last active January 17, 2022 03:51
Implementation of Kaiser windowed sinc functions after Graham Hicks's 2002 Geophysics paper
HC_KAISER = {
1: 1.24,
2: 2.94,
3: 4.53,
4: 6.31,
5: 7.91,
6: 9.42,
7: 10.95,
8: 12.53,
9: 14.09,
@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
#!/bin/bash
cat << END
<html>
<body>
<pre style="font-family: consolas,monospace;font-size:8pt">
END
cat -
@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
@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
#
# 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
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')
@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;
@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:]