PEP: | XX |
---|---|
Title: | Build system abstraction for pip/conda etc |
Version: | |
Last-Modified: | |
Author: | Robert Collins <rbtcollins@hp.com>, Nathaniel Smith <njs@pobox.com> |
Discussions-To: | distutils-sig <distutils-sig@python.org> |
Status: | Draft |
Type: | Standards Track |
Content-Type: | text/x-rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deploy instance, copy image in to /mnt/foo.qcow2 | |
apt-get install qemu-utils | |
modprobe nbd max_part=16 | |
qemu-nbd -c /dev/nbd1 imagefile | |
mkdir /mnt/2 | |
mount /dev/nbd1p1 /mnt/2 | |
rsync -axv /mnt/2/ / --delete-after | |
apt-get install qemu-utils | |
umount /mnt/2 | |
qemu-nbd -d /dev/nbd1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Copy this over the contents at tddbin.com | |
//Replace the [] in the assert statements with a functional equivalant | |
//Reference here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array | |
//Lambda syntax: (x,y) => x + y, works in firefox, try it out :) | |
function range(start, end, jump) { | |
jump = jump || 1 | |
if (start && !end) | |
return actualRange(0, start, jump) | |
return actualRange(start, end, jump) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Copy this over the contents at tddbin.com | |
//Replace the [] in the assert statements with a functional equivalant | |
//Reference here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array | |
//Lambda syntax: (x,y) => x + y, works in firefox, try it out :) | |
function range(start, end, jump) { | |
jump = jump || 1 | |
if (start && !end) | |
return actualRange(0, start, jump) | |
return actualRange(start, end, jump) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PyMonad | |
https://pypi.python.org/pypi/PyMonad/ | |
Doesn't duck type Writer - subclass | |
class StringWriter(Writer): | |
logType = str | |
PyMonads | |
https://github.com/dustingetz/pymonads | |
Doesn't duck type Writer: | |
https://github.com/dustingetz/pymonads/blob/master/writer.py#L6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import * | |
pythonapi.PyDict_SetItemString.argtypes=[c_void_p, c_char_p, c_void_p] | |
class PyObject(Structure): | |
_fields_ = [("refcnt", c_size_t), | |
("typeid", c_void_p)] | |
pythonapi.PyThreadState_GetDict.restype = POINTER(PyObject) | |
pythonapi.PyDict_SetItemString(c_void_p(id(locals())), b"threaddict", pythonapi.PyThreadState_GetDict()) | |
repr([1]) | |
print(threaddict) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HandleEvent(testtools.StreamResult): | |
def __init__(self, callback): | |
self._buffers = {} | |
self._callback = callback | |
def status(self, test_id=None, test_status=None, test_tags=None, | |
runnable=True, file_name=None, file_bytes=None, eof=False, | |
mime_type=None, route_code=None, timestamp=None): | |
if not test_id: | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
f = open('income-distribution.csv', 'rt') | |
l = list(csv.reader(f)) | |
pre = l[5:157] | |
# top edge, lower edge, % | |
brackets = [(14000, 0, 0.105), (48000, 14001, 0.175), (70000, 48001, 0.30), (200000, 70001, 0.33)] | |
total = 0 | |
for (_, people, total_income, _) in pre: | |
people = float(people) | |
total_income = float(total_income) * 1000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import methodcaller | |
import random | |
import itertools | |
def card_values(card): | |
"""Get the possible values of a card in a blackjack game. | |
e.g. card_values(0) -> (1, 11) | |
:return: A tuple of the possible values. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from testresources import OptimisingTestSuite | |
def load_tests(standard_tests, module, loader): | |
# top level directory cached on loader instance | |
this_dir = os.path.dirname(__file__) | |
package_tests = loader.discover(start_dir=this_dir, pattern=pattern) | |
standard_tests.addTests(package_tests) | |
return OptimisingTestSuite(standard_tests) |
OlderNewer