Skip to content

Instantly share code, notes, and snippets.

View BrianHicks's full-sized avatar

Brian Hicks BrianHicks

View GitHub Profile
@BrianHicks
BrianHicks / splode
Created March 21, 2014 19:54
semi-useful scripts for working with Fleet
#!/bin/bash
conf=$1
count=$2
if [ -z "${conf}" ] || [ -z "${count}" ]; then
echo "Usage: $0 conf count" 1>&2
exit 1
fi
dir=$(echo $conf | sed "s/service/instances/")
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):
fakemail: python fakemail.py localhost ${MAIL_PORT:-4467}

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:

# 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]]
"""\
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):

Think Python

Chapters 9-12

Chapter 9

Word Play

DEMO

# the following is a basically functional but probably broken for some cases (just tested for basic login ATM) implementation of a flask-security UserDataStore for RethinkDB.
#
# This is released as open source under the MIT license and comes with no warranty, yada yada. TODO: actual license header
from flask_security import UserMixin, RoleMixin
from flask_security.datastore import UserDatastore
import rethinkdb as r
class Bunch(object):
def __init__(self, obj, **kws):
self.__dict__.update(obj)
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
@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 {