Skip to content

Instantly share code, notes, and snippets.

View BrianHicks's full-sized avatar

Brian Hicks BrianHicks

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Think Python

Chapters 4-6

Chapter 4

Case study: Turtle

4.2 (Flowers)

@BrianHicks
BrianHicks / storage-and-syncing.md
Created February 2, 2014 22:01
Data Storage and Syncing

Data Storage and Syncing with LevelDB

So here's a thought for a Go interface that would store data to memory or disk and sync it with other instances in an intermittently connected manner.

Querying

The store looks like this:

type Range struct {
from datetime import datetime
class W(object):
def __getattr__(self, attr):
def meta(*args, **kwargs):
def inner(value):
return getattr(value, attr)(*args, **kwargs)
return inner
return meta

Think Python

Chapters 9-12

Chapter 9

Word Play

DEMO

"""\
TinyObj does the bare minimum to make a nice object layer on top of datastores
which return dicts. It can set defaults, validate data types, and provides a
dot-access style interface for getting and setting attributes (truthfully,
because it just sprinkles a little magic Python dust over the dicts so they are
full Python objects with all of those qualities.)
"""
import datetime
class Field(object):
# I'd like to be able to define a service something like the following...
name = "Some Python Webapp"
[environment.production]
DJANGO_SETTINGS_MODULE=testapp.settings.production
[environment.staging]
DJANGO_SETTINGS_MODULE=testapp.settings.staging
[[service]]

Keybase proof

I hereby claim:

  • I am brianhicks on github.
  • I am brianhicks (https://keybase.io/brianhicks) on keybase.
  • I have a public key whose fingerprint is 8638 C01E DE05 F97D A7A6 89E2 FF1F 407C 0D3C 2430

To claim this, I am signing this object:

fakemail: python fakemail.py localhost ${MAIL_PORT:-4467}
import random
sherlock = open('sherlock-normalized.txt', 'r').read()
sherlock[100:200]
# look at each word (DONE)
# look at the next word in the sequence
# add the next word to the list of words following the first word
class Markov(object):