Skip to content

Instantly share code, notes, and snippets.

View bjmc's full-sized avatar

Brendan McCollam bjmc

View GitHub Profile
@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?
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 / 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 cProfile
cProfile.run("""
f = lambda x: x*2
for i in xrange(10000000):
f(i)
""")
cProfile.run("""
f = lambda x: x*2
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
@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/