Skip to content

Instantly share code, notes, and snippets.

View sgammon's full-sized avatar
:shipit:
f*ck it, ship it

Sam Gammon sgammon

:shipit:
f*ck it, ship it
View GitHub Profile
@sgammon
sgammon / person.py
Created July 30, 2013 23:49
This sample demos the apptools model layer, which provides an expressive syntax for data modeling and a framework of adapters to allow engine agnostic storage.
# -*- coding: utf-8 -*-
'''
models: sample
:author: Sam Gammon (sam@momentum.io)
:copyright: (c) 2013 momentum labs.
:license: This is private source code - all rights are reserved. For details about
embedded licenses and other legalese, see `LICENSE.md`.
'''
@sgammon
sgammon / sample.py
Created July 30, 2013 23:39
Self-contained example of a full apptools RPC service. Includes a `model.Model`-based RPC message class and service exception. This is literally all the code you need to write in apptools to deploy a service - once this file is autoloaded at construction time, the service appears in apptools JS at `$.apptools.api.sample.echo()`.
# -*- coding: utf-8 -*-
'''
api sample: service
:author: Sam Gammon (sam@momentum.io)
:copyright: (c) 2013 momentum labs.
:license: This is private source code - all rights are reserved. For details about
embedded licenses and other legalese, see `LICENSE.md`.
'''
@sgammon
sgammon / service.py
Created June 18, 2013 23:23
Association service
# -*- coding: utf-8 -*-
# apptools RPC
from apptools import rpc
## TrackerException - abstract parent for all exceptions related to :py:class:`Tracker`.
class TrackerException(rpc.remote.ApplicationError): pass
# -*- coding: utf-8 -*-
"""
Runserver for apptools-based services and handlers.
"""
from gevent import pywsgi
from apptools import dispatch
# make our variables
vowels = ['a', 'e', 'i', 'o', 'u']
words = ['here', 'yup', 'nnn', 'bllble']
# empty results list that will contain tuples of (<word>, <vowel>) where `vowel` is `True` or `False`
results = []
for word in words:
for vowel in vowels:
if vowel in word:
@sgammon
sgammon / __init__.py
Last active December 17, 2015 11:58
The new apptools Model API!
# -*- coding: utf-8 -*-
"""
Welcome to the :py:mod:`apptools` Model API! Using this package, you can model data,
interact with datastore layers through Model Adapters (see: :py:mod:`adapters`),
and generate messages for use with Service classes.
:author: Sam Gammon (sam@momentum.io)
:copyright: (c) 2013 momentum labs.
:license: This is private source code - Ampush has been granted an
@sgammon
sgammon / base64.js
Last active December 17, 2015 05:59
/*
*
* Base64 for JavaScript
* -- A clean and compact implementation --
*
* @author Sam Gammon <sg@samgammon.com>
*/
(function (context) {
var Base64 = context.Base64 = {
@sgammon
sgammon / model.py
Last active December 15, 2015 18:19
# -*- coding: utf-8 -*-
'''
apptools2: model API
-------------------------------------------------
| |
| `apptools.model` |
| |
| a general-purpose, minimalist toolkit for |
@sgammon
sgammon / aj.py
Last active December 14, 2015 02:59
from protorpc import messages
from apptools import services
## Request message
class HelloRequest(messages.Message):
''' Request ProtoRPC message for `AJ.hello`. '''
name = messages.StringField(1, default='AJ')
@sgammon
sgammon / Like Action.json
Created January 30, 2013 01:52
Yoga's implementation of OG built-in Watch actions
{
"id": "10152532360095651",
"from": {
"name": "<user's name>",
"id": "<user's fbid>"
},
"start_time": "2013-01-30T01:42:18+0000",
"end_time": "2013-01-30T01:42:18+0000",
"publish_time": "2013-01-30T01:42:18+0000",
"application": {