Skip to content

Instantly share code, notes, and snippets.

:shipit:
f*ck it, ship it

Sam Gammon sgammon

:shipit:
f*ck it, ship it
Block or report user

Report or block sgammon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sgammon
sgammon / filterKeenData.js
Last active Dec 22, 2015
JavaScript snippet to sanitize odd characters from keys, and build hierarchy where nested keys exist ("dot.paths.like.this"). Version 3 :).
View filterKeenData.js
// `filterKeenData`: removes invalid property keys and expands nested keys
var filterKeenData = (function () {
'use strict';
var _stop_list = [/\./g], // stop list dictates where we nest, strip list is char regexes to remove
_strip_list = [/\./g, /\|/g, /\\/g, /\&/g, /\?/g, /\:/g, /\;/g, /\~/g, /\!/g, /@/g, /#/g, /\//g, /'/g],
// `_filter_string`: filter a string of invalid characters
_filter_string = function (original) {
var strip_i, strip_c, _sanitized = original;
if (typeof original === 'string') {
@sgammon
sgammon / person.py
Created Jul 30, 2013
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.
View person.py
# -*- 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 Jul 30, 2013
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()`.
View sample.py
# -*- 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 Jun 18, 2013
Association service
View service.py
# -*- 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
View main.py
# -*- coding: utf-8 -*-
"""
Runserver for apptools-based services and handlers.
"""
from gevent import pywsgi
from apptools import dispatch
View quick.py
# 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 Dec 17, 2015
The new apptools Model API!
View __init__.py
# -*- 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
View base64.js
/*
*
* Base64 for JavaScript
* -- A clean and compact implementation --
*
* @author Sam Gammon <sg@samgammon.com>
*/
(function (context) {
var Base64 = context.Base64 = {
View model.py
# -*- coding: utf-8 -*-
'''
apptools2: model API
-------------------------------------------------
| |
| `apptools.model` |
| |
| a general-purpose, minimalist toolkit for |
View aj.py
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')
You can’t perform that action at this time.