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 sys | |
from_string = sys.argv[1] | |
to_string = sys.argv[2] | |
with open("input.txt") as f: | |
text = f.read() | |
text = text.replace(from_string, to_string) |
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 do this ... */ | |
load: function(url) { | |
setTimeout(function () { doload(url) }, 1); | |
} | |
doload: function (url) { | |
/* synchronous XHR */ | |
xhr.open("GET", url, false); | |
xhr.send(null); |
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/python3 | |
import glob | |
import json | |
import sys | |
import os | |
from urllib.parse import urlparse | |
# download from https://github.com/pirate/sites-using-cloudflare/ | |
cloudflare_tlds = frozenset(map(lambda x:x.strip(), | |
open("sites-using-cloudflare-master/sorted_unique_cf.txt"))) |
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/python | |
import re | |
import subprocess | |
import sys | |
import time | |
import datetime | |
def parse_date(date): | |
dt = datetime.datetime.strptime(date, "%b %d %H:%M:%S %Y GMT") |
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 traceback | |
import re | |
def debug_var(a): | |
s = traceback.extract_stack(limit=2)[0][3] | |
g = re.match("\w+\((\w+)\)", s) | |
print("%s = %r" % (g.group(1), a)) | |
def main(): | |
foo=1 |
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
### Hettinger's way | |
# robot.py | |
class Robot(object): | |
def move(self): | |
print('Movement') | |
class CleaningRobot(Robot): | |
def clean(self): |
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
# pizza.py | |
class DoughFactory(object): | |
def get_dough(self): | |
return 'insecticide treated wheat dough' | |
class Pizza(DoughFactory): | |
def order_pizza(self, *toppings): |
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 Player: | |
"""Base class for the algorithm controlling a receiver and/or transmitter. | |
Users should derive their own classes from this one and override | |
methods as necessary. | |
class MyPlayer(Player): | |
... | |
The system creates two instances: one controlling the receiver and one |
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
py32-latest create: /home/avian/dev/opencontracting/jsonmerge/.tox/py32-latest | |
py32-latest installdeps: jsonschema | |
ERROR: invocation failed, logfile: /home/avian/dev/opencontracting/jsonmerge/.tox/py32-latest/log/py32-latest-1.log | |
ERROR: actionid=py32-latest | |
msg=getenv | |
cmdargs=[local('/home/avian/dev/opencontracting/jsonmerge/.tox/py32-latest/bin/pip'), 'install', 'jsonschema'] | |
env={'PYTHONIOENCODING': 'utf_8', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'WINDOWPATH': '7', 'LOGNAME': 'avian', 'USER': 'avian', 'GNOME_KEYRING_CONTROL': '/home/avian/.cache/keyring-im0pyK', 'LC_PAPER': 'sl_SI.UTF-8', 'PATH': '/home/avian/dev/opencontracting/jsonmerge/.tox/py32-latest/bin:/home/avian/src/depot_tools:/home/avian/local/eagle-5.11.0/bin:/home/avian/local/bin:/home/avian/syn/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin', 'DISPLAY': ':0', 'SSH_AGENT_PID': '12184', 'LANG': 'en_US.utf8', 'TERM': 'xterm', 'SHELL': '/bin/bash', 'XDG_SESSION_COOKIE': '4aaab8b188ece36029e4747a00000014-1407223324.605827-1316331910', |
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
# vim:ts=4 sw=4 expandtab softtabstop=4 | |
import json | |
import jsonschema | |
def main(): | |
record = json.load(open("blank-ocds.json")) | |
schema = json.load(open("../standard/standard/schema/record-schema.json")) | |
jsonschema.validate(record, schema) | |
main() |
NewerOlder