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 python3 | |
# -*- coding: utf-8 -*- | |
# | |
# | |
import json | |
import os | |
from random import choice, gauss, sample, randint | |
from datetime import datetime | |
import re |
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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:093e4d7561eebe0a00236a799d36efc6bdc0dd00e7517505b7ab14026324aef7" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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 SignedObjectMixin(object): | |
@property | |
def signed(self): | |
if hasattr(self, '__sig__'): | |
return sign(self) | |
raise NotImplemented('no __sig__ found') | |
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 InitAllMixin(object): | |
def __init__(self, *args, **kwargs): | |
for base in (c for c in self.__class__.__bases__ if c is not InitAllMixin): | |
base_class.__init__(self, *args, **kwargs) | |
class BaseClassOne(object): | |
spam_message = "class_spam" | |
def __init__(self): | |
self.spam_message = "instance_spam" |
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 collections | |
def strict_iterator(iterable): | |
if not isinstance(iterable, collections.Iterable): | |
raise StopIteration | |
else: | |
for i in iterable: | |
yield i | |
def safe_iterator(iterable): |
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
<html> | |
<table> | |
<tr><th>environ</th><th>color</th></tr> | |
<tr><td>local</td><td bgcolor=Pink>Pink</td></tr> | |
<tr><td>beta</td><td bgcolor=MediumPurple>MediumPurple</td></tr> | |
<tr><td>dev</td><td bgcolor=LimeGreen>LimeGreen</td></tr> | |
<tr><td>prod</td><td bgcolor=Crimson>Crimson</td></tr> | |
<tr><td>review</td><td bgcolor=HotPink>HotPink</td></tr> | |
<tr><td>stage</td><td bgcolor=Orange>Orange</td></tr> | |
<tr><td>stress</td><td bgcolor=LightSeaGreen>LightSeaGreen</td></tr> |
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 qrcode | |
with open(__file__) as ofile: | |
mcnts = ofile.read()[:-1] | |
qrcode.make(mcnts).save('quine_qr.png') | |
print(mcnts) |
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
## calling this url will return a QR code which encodes the str_in parameter: | |
url = 'chart.apis.google.com/chart?cht=qr&chs=300x300&chl={str_in}&chld=H|0'.format(str_in='') | |
## find a str_in such that the generated QR code, when scanned, returns the url which generated it |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 contextlib import contextmanager | |
from functools import wraps | |
class dummy_statsd_connection(object): | |
def __init__(self, *args, **kwargs): | |
self.data = [] | |
self.log_data(args, kwargs) | |
def log_data(self, *args, **kwargs): | |
self.data.append({'args':args, 'kwargs':kwargs}) |
NewerOlder