Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
@gregorynicholas
gregorynicholas / gist:1564364
Created January 5, 2012 09:10 — forked from kylefinley/gist:1059647
webapp2 auth User model
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import datetime
from ndb import model
from webapp2_extends.utils import Unique, UniqueConstraintViolation, \
check_password_hash, generate_password_hash
from webapp2_extends.auth import create_session_id
DEBUG = True
@gregorynicholas
gregorynicholas / withings.py
Created January 12, 2012 01:53 — forked from pamelafox/withings.py
Withings Python OAuth Wrapper
# -*- coding: utf-8 -*-
# Based on https://github.com/ikasamah/withings-garmin/blob/master/withings.py
import urllib
from datetime import datetime
import urlparse
import oauth2 as oauth
try:
import json
@gregorynicholas
gregorynicholas / gist:1598043
Created January 12, 2012 01:55 — forked from pamelafox/gist:1006753
Sendgrid Python Web API example
import urllib2, urllib
import logging
def send_mail_sendgrid(from, to, subject, body):
base_url = 'https://sendgrid.com/api/mail.send.json'
params = {
'api_user': 'you@you.com',
'api_key': 'yourpassword',
'from': from,
'to': to,
@gregorynicholas
gregorynicholas / gist:1610004
Created January 14, 2012 02:34 — forked from kylefinley/gist:1059647
webapp2 auth User model
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import datetime
from ndb import model
from webapp2_extends.utils import Unique, UniqueConstraintViolation, \
check_password_hash, generate_password_hash
from webapp2_extends.auth import create_session_id
DEBUG = True
@gregorynicholas
gregorynicholas / forms.py
Created January 14, 2012 02:34 — forked from kylefinley/forms.py
webapp2: Password reset
import models
from wtforms import Form
from wtforms import fields
from wtforms import validators
class PasswordRestForm(Form):
email = fields.TextField('email')
class PasswordChangeForm(Form):
current = fields.PasswordField('Current Password')
@gregorynicholas
gregorynicholas / rpcspy.py
Created February 28, 2012 18:53 — forked from groks/rpcspy.py
log appengine rpc's
from google.appengine.api import (
apiproxy_stub_map,
quota
)
import logging
def _log_api_pre_call(service, call, request, response, rpc):
logging.debug('RPC(pre) %s.%s', service, call)
def _log_api_post_call(service, call, request, response, rpc, error):
@gregorynicholas
gregorynicholas / Makefile
Created February 28, 2012 18:51 — forked from mdornseif/Makefile
GIT tag deploys for AppEngine
deploy: dependencies check
# index must be clean (no modified files)
git diff-index --quiet --cached HEAD
# no uncomitted changes
git diff-files --quiet
# create a branch for the current version
git branch -f deploy_`grep -E '^version: ' app.yaml | cut -d ' ' -f 2`
# push current code to that branch
git push -f . deploy_`grep -E '^version: ' app.yaml | cut -d ' ' -f 2`
@gregorynicholas
gregorynicholas / zipimport.py
Created May 26, 2012 16:02 — forked from skorokithakis/zipimport.py
Import zips and eggs for AppEngine.
import sys, os
package_dir = "packages"
sys.path.insert(0, package_dir)
for filename in os.listdir(package_dir):
if filename.endswith((".zip", ".egg")):
sys.path.insert(0, "%s/%s" % (package_dir, filename))
@gregorynicholas
gregorynicholas / ae.py
Created June 4, 2012 07:58 — forked from chrisfarms/ae.py
An google-appengine loading module to aid writing scripts for GAE
######################################################
# allow scripts to use appengine apis
#
# assumes you store your data in a "data" directory
# in your app directory. See connect_local_datastore()
# and assumes that you have a HRD app id with "~"
######################################################
#
# locate app-engine SDK:
AE_PATH = "/your/path/to/sdk/google_appengine/"
@gregorynicholas
gregorynicholas / fabfile.py
Created June 4, 2012 08:13 — forked from jeremi/fabfile.py
A fabfile to manage git+appengine deployement
from __future__ import with_statement
import functools
import os
import sys
from fabric.api import *
from fabric.colors import green, red, green
import datetime
import re