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
{ | |
"cards": [ | |
{"p": 0.23, "s": true, "e": 35, "n": "A Display of My Dark Power"}, | |
{"p": 1.8, "s": true, "e": 14, "n": "Abbot of Keral Keep"}, | |
], | |
"editions": [ | |
"", "Shards of Alara", "Morningtide", "3rd Edition", "Commander's Arsenal", | |
"Duel Decks: Phyrexia vs. The Coalition", "Planar Chaos", "Dissension", | |
"Duel Decks: Garruk vs Liliana", "Duel Decks: Heroes Vs. Monsters", | |
"Homelands", "Duels of the Planeswalkers", "Unlimited", "Portal 3K", |
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
''' | |
Character substitution | |
==== | |
Not handled at all. Should be reasonably straightforward to plug into the existing code. | |
Roughly: | |
def expand_substitutions(wordlist, sub_map): | |
for word in wordlist: | |
for substitution in expand_word(word, sub_map): | |
yield substitution |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
</head> | |
<body> | |
<div>Type some stuff and click send (or hit enter)</div> | |
<input type='text' id='input' onkeyup="onKeyUp(event)" autofocus="autofocus"></input> | |
<button onclick='send_text()'>Send</button> | |
<div id='output'></div> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
</head> | |
<body> | |
<div>Transferring an array</div> | |
<button id='bPopulate' onclick='populateArray()'>Populate Array</button> | |
<button id='bSend' onclick='sendArray()'>Send Array</button> | |
<div id='output'></div> |
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
#!/bin/bash | |
#================= | |
# commands: | |
# volume : get volume | |
# volume [0,100] : set volume, unmute | |
# volume [up|down] : step volume up or down by small pct, unmute | |
# volume mute : toggle mute | |
# volume muted : exit 0/print true if muted, else exit 0/print false | |
#================= |
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
""" | |
# First argument to the function should be the next | |
# object to invoke (next_handler below) | |
class EventHandler(object): | |
def __init__(self, name): | |
self.name = name | |
def handle(self, next_handler, event, data): | |
print("ENTER: Handler {} Event {}".format(self.name, event)) |
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
""" | |
Why is __call__ a special case? | |
https://docs.python.org/3.4/reference/datamodel.html#object.__getattribute__ | |
> Note: This method may still be bypassed when looking up special methods as the result of implicit invocation via language syntax or built-in functions. See Special method lookup. | |
> In addition to bypassing any instance attributes in the interest of correctness, implicit special method lookup generally also bypasses the __getattribute__() method even of the object’s metaclass | |
""" | |
class Chain(object): |
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 build_index(*fields): | |
'''each arg is (field_name, length) tuple''' | |
index = type('Index', (object,), {}) | |
start = 0 | |
for field, offset in fields: | |
s = slice(start, start + offset) | |
setattr(index, field, s) | |
start += offset | |
return index |
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
SUMMARY | |
============================= | |
bartell's gift card | |
toothpaste | |
thermos | |
soap dish | |
chapstick | |
tictacs | |
shower gel | |
shaving cream |
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
"[name] is [age:int] years old." -> "(?<name>[^ ]) is [(?<age>\d+) years old \." | |
---------------------------------------- | |
Examples | |
"search [service]/[region] [metric]" | |
"search (?<service>[^ ^/]+)/(?<region>[^ ]+) (?<metric>[^ ]+)" | |
"stock (?<name>[^ ]) (?<op>((<|>|=)=?)) (?<value>[^ ]+)" |
OlderNewer