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?
>>> 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 .....................................
@bjmc
bjmc / -
Created November 26, 2014 17:52
Package files:
100 /var/lib/dpkg/status
release a=now
500 http://extras.ubuntu.com/ubuntu/ utopic/main i386 Packages
release v=14.10,o=LP-PPA-app-review-board,a=utopic,n=utopic,l=Application Review Board PPA,c=main
origin extras.ubuntu.com
500 http://extras.ubuntu.com/ubuntu/ utopic/main amd64 Packages
release v=14.10,o=LP-PPA-app-review-board,a=utopic,n=utopic,l=Application Review Board PPA,c=main
origin extras.ubuntu.com
500 http://archive.canonical.com/ubuntu/ utopic/partner Translation-en
sudo cp migrate_to_sql.py /mnt/globus_deploy/apps/nexus/current/graph/lib/python2.7/site-packages/globusonline-RELEASE_2011_06_06-py2.7.egg/globusonline/graph/admin/migrate_to_sql.py
from globusonline.graph.admin.migrate_to_sql import clear_sql_db, initialize_sql_db, migrate_to_sql
from globusonline.graph.sql import SQLManager, Base
sql_manager = SQLManager()
clear_sql_db(sql_manager.engine(), Base)
initialize_sql_db(sql_manager.engine(), Base)
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 / 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