Skip to content

Instantly share code, notes, and snippets.

View tav's full-sized avatar

tav

View GitHub Profile
"""
Utility functions for OpenSSL.
"""
import sys
from OpenSSL import crypto
from OpenSSL import SSL
<tav> Foo Hello *bar* Yes
<jeffarch> Oh Yes! Foo Bar
def get_canonical_plexname(plexname):
"""Return a canonicalised form of a plexname."""
if not isinstance(plexname, unicode):
plexname = unicode(plexname, 'utf-8')
# @/@ this has lotsa skope for optimisation. also, need to choose between:
# NFKD(toCasefold(NFKD(toCasefold(NFD(X)))))
# NFD(toCasefold(NFD(X)))
$ cd third_party/generic/
$ rm -rf pypy
$ svn co svn+ssh://codespeak.net/svn/pypy/trunk pypy >> /dev/null
# all set to go -- if something changes on svn, just svn up ...
# likewise, one can make changes in the codespeak repo and svn commit...
$ svn up >> /dev/null
$ git-status
@tav
tav / Source.py
Created June 6, 2009 09:00
Copyright header format in source code
# This file has been placed into the Public Domain by:
#
# Your Name <you@domain.com>
#
# See documentation/license.txt for more info.
"""Documentation string."""
from decimal import Decimal
def profit(price, current, bid_increase=Decimal('0.15'), bid_price=Decimal('0.75')):
price, current = Decimal(price), Decimal(current)
bids = current / bid_increase
total = (bids * bid_price)
if current < price: current = 0
profit = total - price + current
# print "# of bids:", bids
# print "profit:", profit
$ plexnet --test --summary
--------------------------------------------------------------------------------
Doctest Summary
--------------------------------------------------------------------------------
1 plexnet.util secure 33 PASSED
2 plexnet.core builtins 8 PASSED
capbase 14 PASSED
[translation:ERROR] Error:
[translation:ERROR] Traceback (most recent call last):
[translation:ERROR] File "third_party/generic/pypy/pypy/translator/goal/translate.py", line 273, in main
[translation:ERROR] drv.proceed(goals)
[translation:ERROR] File "/Users/tav/work/third_party/generic/pypy/pypy/translator/driver.py", line 704, in proceed
[translation:ERROR] return self._execute(goals, task_skip = self._maybe_skip())
[translation:ERROR] File "/Users/tav/work/third_party/generic/pypy/pypy/translator/tool/taskengine.py", line 116, in _execute
[translation:ERROR] res = self._do(goal, taskcallable, *args, **kwds)
[translation:ERROR] File "/Users/tav/work/third_party/generic/pypy/pypy/translator/driver.py", line 267, in _do
[translation:ERROR] res = func()
[user]
email = tav@espians.com
name = tav
[color]
diff = auto
status = auto
branch = auto
[github]
user = tav
# ctypes/macholib/dyld.py needs to be monkeypatched with:
def dyld_default_search(name, env=None):
yield name
framework = framework_info(name)
if framework is not None:
fallback_framework_path = dyld_fallback_framework_path(env)
for path in fallback_framework_path: