Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View blbradley's full-sized avatar

Brandon Bradley blbradley

  • Nashville, TN
View GitHub Profile
@blbradley
blbradley / runapp.py
Created November 6, 2014 22:38
WebOb middleware to force ssl on Heroku
import os
from webob.dec import wsgify
from webob.exc import HTTPMovedPermanently
from paste.deploy import loadapp
from waitress import serve
@wsgify.middleware
def ForceSSLMiddleware(req, app):
@blbradley
blbradley / build.gradle
Last active August 29, 2015 14:10
gradle file for running Apache Storm locally
apply plugin: 'java'
repositories {
mavenCentral()
maven {
url 'http://clojars.org/repo/'
}
}
dependencies {
@blbradley
blbradley / pandas_compare.py
Last active August 29, 2015 14:14
pandas 'Is a Timestamp within a Period?'
from pandas.core.api import Timestamp, Period
time_in_seconds = Timestamp('2013-03-31 22:11:19')
one_year_period = Period('2013')
time_in_seconds.to_period(one_year_period.freq) == one_year_period
# True
@blbradley
blbradley / 01-vb_suite.log
Created February 17, 2015 01:00
vbench results for pandas #9440
Invoked with :
--ncalls: 5
--repeats: 5
-------------------------------------------------------------------------------
Test name | head[ms] | base[ms] | ratio |
-------------------------------------------------------------------------------
timeseries_with_format_no_exact | 447.1206 | 467.2980 | 0.9568 |
@blbradley
blbradley / 01-vb_suite.log
Created February 17, 2015 16:38
vbench results for pandas #9504
Invoked with :
--ncalls: 5
--repeats: 5
-------------------------------------------------------------------------------
Test name | head[ms] | base[ms] | ratio |
-------------------------------------------------------------------------------
period_setitem | 8.4562 | 9.3834 | 0.9012 |
@blbradley
blbradley / pandas_test_fast
Created February 19, 2015 16:49
./test_fast results for using NotImplemented in Period.__richcmp__ - pandas #9504
======================================================================
FAIL: test_greaterEqual_Raises_Value (pandas.tseries.tests.test_period.TestComparisons)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/brandon/src/coins/pandas/pandas/tseries/tests/test_period.py", line 2825, in test_greaterEqual_Raises_Value
print(self.january1 >= 1)
File "/home/brandon/src/coins/pandas/pandas/util/testing.py", line 1644, in __exit__
raise AssertionError("{0} not raised.".format(name))
AssertionError: TypeError not raised.
-------------------- >> begin captured stdout << ---------------------
@blbradley
blbradley / xmlurls.sh
Created February 8, 2013 19:43
Print a list of URLs from an XML sitemap to stdout
#Print a list of URLs from sitemap.xml to stdout
xpath -q -e '/*/*/*/text()' sitemap.xml
@blbradley
blbradley / post-receive-puppetbranches
Last active December 14, 2015 23:38
git post-receive hook for tracking puppet environments on the same machine
#!/bin/sh
read oldrev newrev refname
REPO="/my/repo.git"
BRANCH=`echo $refname | sed -n 's/^refs\/heads\///p'`
BRANCH_DIR="/etc/puppet/environments"
#Unset GIT_DIR and GIT_WORK_DIR so git chooses them by current directory
#Based on behaviour of git post-receive hook, undocumented
unset GIT_DIR
@blbradley
blbradley / git-list-dirs.sh
Created July 28, 2013 22:43
List all directories tracked by a git repo
#!/bin/sh
# Run in the project's root
git ls-files | sed 's:[^/]*$::'| sed '/^$/d' | sort -u
@blbradley
blbradley / git-sftp-deploy.sh
Created July 28, 2013 23:32
Deploy over SFTP, for those moments when your host tells you to go fuck yourself.
#!/bin/sh
# Requirements:
# Install expect and make sure it's on your path
# sftp with working '-r' option
GIT_DIR=$1
HOST=$2
PASSWORD=$3