Skip to content

Instantly share code, notes, and snippets.

View tacaswell's full-sized avatar

Thomas A Caswell tacaswell

View GitHub Profile
@tacaswell
tacaswell / demo.py
Last active August 29, 2015 14:06
pandas play
import pandas as pd
from datetime import datetime, timedelta
dt = timedelta(seconds=1)
base_time = datetime(2014, 9, 24, 10, 5, 30)
indx1 = [base_time + j * dt for j in range(0, 10)]
indx2 = [base_time + j * dt for j in range(0, 10, 2)]
ds1 = pd.Series(5, index=indx1)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tacaswell
tacaswell / jsonschema_play.py
Created January 31, 2015 02:43
jschema_play
from jsonschema import validate
schema = {
"definitions": {
"data_key": {
"properties": {
"external": {
"type": "string",
"pattern": "^[A-Z]+:?"
},
@tacaswell
tacaswell / tupper.ipynb
Last active August 29, 2015 14:19
Notebook demonstrating Tupper's Self-Referential Formula
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
sys.setrecursionlimit(10000)
class Meta(type):
def __new__(*args, **kwargs):
print('I will not use metaclasses just for the fun of using them', end=' ')
magic_count = kwargs.pop('__magic_count', 0)
if magic_count > 1000:
return type.__new__(*args, **kwargs)
Meta.__new__(__magic_count=magic_count+1, *args, **kwargs)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class Document(dict):
def __init__(self, name, *args, **kwargs):
self._name = name
super(Document, self).__init__(*args, **kwargs)
def __getattr__(self, key):
return self[key]
def __setattr__(self, key, value):