Skip to content

Instantly share code, notes, and snippets.

View bjmc's full-sized avatar

Brendan McCollam bjmc

View GitHub Profile
@bjmc
bjmc / test_click_to_call.py
Last active December 15, 2015 01:19
Demonstration of testing a click-to-call service using Google voice
import unittest
import urllib2
from urllib import urlencode
from time import sleep, time
import logging
logging.basicConfig(level=logging.DEBUG)
from googlevoice import Voice
# https://code.google.com/r/bwpayne-pygooglevoice-auth-fix/
h$ dig SPF globusonline.org
; <<>> DiG 9.9.2-P1 <<>> SPF globusonline.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39078
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
import cProfile
cProfile.run("""
f = lambda x: x*2
for i in xrange(10000000):
f(i)
""")
cProfile.run("""
f = lambda x: x*2
@bjmc
bjmc / populateValues.js
Created August 30, 2013 15:15
This is a silly little helper function to fill in all the values for a new Zuora hosted payment page
function populateValues(hosted_domain, environment) {
var $ = jQuery;
$('#pageName').val('Add Credit Card' + ' - ' + environment);
$('#domain').val(hosted_domain);
$('input[name="pageTitle"]').val('Credit Card');
$('#callbackPath').val('/service/graph/billing/callback');
$('#paymentGateway').val('2c92c0f83f54bdef013f59ce65d87719');
var css_data = "body {\n width: 100%;\n padding: 0;\n margin: 0;\n color: #333333;\n font-family: \"Helvetica Neue\",Arial,Helvetica,sans-serif;\n font-size: 14px;\n line-height: 1.5; }\n\ntable {\n border: 0 none;\n border-collapse: collapse;\n border-spacing: 0;\n margin-top: 10px;\n width: 100%; }\n\n.z_hppm_field_label_cell {\n font-size: 1.1em;\n text-align: right;\n vertical-align: middle;\n width: 48%;\n padding: 0 1%;\n border: 0;\n display: block;\n float: left; }\n\n.z_hppm_field_value_cell {\n vertical-align: middle;\n border: 0;\n padding: 0 1%;\n display: block;\n float: left; }\n\n.z_hppm_input_cardSecurityCode {\n
import uuid
# based on http://stackoverflow.com/questions/3795554/extract-the-time-from-a-uuid-v1-in-python
def uuid_to_timestamp(uuid_hex_string):
uid = uuid.UUID(hex=uuid_hex_string)
return (u.time - 0x01b21dd213814000L)*100/1e9
def reorder_uuid(uuid_hex_string):
parts = uuid_hex_string.split('-')
return '-'.join((parts[2], parts[1], parts[0], parts[3], parts[4]))
@bjmc
bjmc / output.txt
Last active August 29, 2015 14:02
Why don't these match?
3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2]
2014.4
<DstTzInfo 'Europe/Berlin' LMT+0:53:00 STD>
<DstTzInfo 'Europe/Berlin' CET+1:00:00 STD>
Traceback (most recent call last):
File "example.py", line 16, in <module>
assert result.tzinfo == tz, "Why aren't these the same timezone?"
AssertionError: Why aren't these the same timezone?
@bjmc
bjmc / install_sentry.sh
Created June 26, 2014 01:32
Basic setup script for installing Sentry (http://getsentry.com) + Redis on new Ubuntu 14.04 Amazon EC2 instance
#! /bin/bash
export RUN_AS='ubuntu';
export INSTALL_DIR='/var/www/sentry';
HOSTNAME='http://mysentry.example.com'; # No trailing slash
DB_HOST='something.rds.amazonaws.com';
DB_PORT='5432';
DB_USER='sentry';
DB_NAME='sentry';
DB_PASSWORD='DB_PASSWORD';
>>> tz = tzlocal.get_localzone()
>>> utc = pytz.timezone("UTC")
>>> utc
<UTC>
>>> import datetime
>>> now = datetime.datetime.now()
>>> now
datetime.datetime(2014, 6, 27, 12, 6, 12, 676354)
>>> tz
<DstTzInfo 'America/Los_Angeles' LMT-1 day, 16:07:00 STD>
@bjmc
bjmc / tox_results.txt
Last active August 29, 2015 14:03
apscheduler tox test results
GLOB sdist-make: /home/bjmc/Sandbox/apscheduler/setup.py
py26 inst-nodeps: /home/bjmc/Sandbox/apscheduler/.tox/dist/APScheduler-3.1.0.dev1.zip
py26 runtests: commands[0] | py.test -rsx
============================= test session starts ==============================
platform linux2 -- Python 2.6.9 -- py-1.4.20 -- pytest-2.5.2
collected 1387 items / 2 errors
.env/lib/python2.7/site-packages/flake8/tests/test_engine.py .....
.env/lib/python2.7/site-packages/pyflakes/test/test_api.py ..........................FFFF
.env/lib/python2.7/site-packages/pyflakes/test/test_doctests.py ...............................................................................................................................................................
GLOB sdist-make: /home/bjmc/Sandbox/apscheduler/setup.py
py26 inst-nodeps: /home/bjmc/Sandbox/apscheduler/.tox/dist/APScheduler-3.1.0.dev1.zip
py26 runtests: commands[0] | py.test -rsx
============================= test session starts ==============================
platform linux2 -- Python 2.6.9 -- py-1.4.20 -- pytest-2.5.2
collected 411 items
tests/test_executors.py ........
tests/test_expressions.py ..........................
tests/test_job.py .....................................