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
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd"> | |
<!--Created by yEd 3.12.2--> | |
<key for="graphml" id="d0" yfiles.type="resources"/> | |
<key for="port" id="d1" yfiles.type="portgraphics"/> | |
<key for="port" id="d2" yfiles.type="portgeometry"/> | |
<key for="port" id="d3" yfiles.type="portuserdata"/> | |
<key attr.name="url" attr.type="string" for="node" id="d4"/> | |
<key attr.name="description" attr.type="string" for="node" id="d5"/> | |
<key for="node" id="d6" yfiles.type="nodegraphics"/> |
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
>>> timeit.timeit("np.array([42]*10000, dtype=float)", "import numpy as np", number=15000) | |
14.971487045288086 | |
>>> timeit.timeit("np.ones(10000, dtype=float) * 42", "import numpy as np", number=15000) | |
0.5964510440826416 | |
>>> timeit.timeit("np.multiply(np.ones(10000, dtype=float), 42)", "import numpy as np", number=15000) | |
0.5582938194274902 |
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
>>> dis.dis(lambda: 10000/2 + 1) | |
1 0 LOAD_CONST 1 (10000) | |
3 LOAD_CONST 2 (2) | |
6 BINARY_DIVIDE | |
7 LOAD_CONST 3 (1) | |
10 BINARY_ADD |
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
#!/usr/bin/env python | |
import urwid | |
thing_to_wrap = urwid.Text(' '.join(str(n) for n in range(1000, 1115))) | |
right_shadow = urwid.Pile([ | |
(1, urwid.SolidFill(' ')), | |
urwid.SolidFill('X')]) | |
bottom_shadow = urwid.Columns([ |
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
def split_bars(v): | |
i = iter(v.split('|')) | |
while True: | |
part = next(i) | |
while part.endswith('\\'): | |
part = part[:-1] + '|' + next(i) | |
yield part.replace('\\\\', '\\') |
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 urwid | |
from urwid.util import calc_width | |
class RTLTextLayout(urwid.TextLayout): | |
""" | |
A toy text layout that arranges all characters from | |
right to left. | |
Only works with unicode strings and narrow characters | |
Currently fails if text is too long for the line |
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
D = """ | |
xxxxxx | |
xx xxxx | |
xxxxxxxx | |
xxxx | |
xxxxxxxxxxxx xxx | |
xxxxxxxxxxxxx xxxx | |
xxxxxxxxxxxxx xxxx | |
xxxx xxxx | |
xxxx xxxxxxxxxxxxx |
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 urllib, urllib2, json | |
class CanLIIException(Exception): | |
def __str__(self): | |
return repr(self.args) | |
class CanLII(object): | |
def __init__(self, api_key, language = 'en'): | |
self.address = "http://api.canlii.org/v1/" |
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 urwid | |
class UnderscoreRight(urwid.StandardTextLayout): | |
def layout(self, text, width, align, wrap): | |
s = urwid.StandardTextLayout.layout(self, text, width, align, wrap) | |
out = [] | |
last_offset = 0 | |
for row in s: | |
used = 0 | |
for seg in row: |
OlderNewer