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 / 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 / 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 / zipme.py
Created March 2, 2012 11:58
ZipMe : GAE Content Downloader
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
##########################################################################
ZipMe : GAE Content Downloader
##########################################################################
Just add this lines in your app.yaml :
- url: /zipme
script: zipme.py
@gregorynicholas
gregorynicholas / usage.py
Created March 2, 2012 12:14
AppEngine worker
class SendAnEmailImmediately(Worker)
def doExecute(self):
logging.info("Sending emails to %s" % lemailStr)
lmessage = mail.EmailMessage(
sender="[email protected]",
to="[email protected]",
subject= "Hi Betty",
body="I know you love email!"
)
lmessage.send()
@gregorynicholas
gregorynicholas / image_histogram.py
Created March 4, 2012 03:57
AppEngine: Get the Weighted Average of Colors in an Image
def weighted_average(values):
'''Multiply the pixel counts (the values in the histogram)
by the pixel values (the index in the values list).
Then add them, to get a weighted sum.
Then divide by the number of pixels to
get the weighted average.'''
weighted_sum = sum(i * values[i] for i in range(len(values)))
num_pixels = sum(values)
@gregorynicholas
gregorynicholas / runtests
Created March 8, 2012 07:00
NOSE test runner command
# install nose, nosegae, gaetestbed, webtest
# the root of your project, where ever the app.yaml for the project is
SRC_PATH=./
# the path to a subfolder or package where the tests are
TESTS_PATH=./test
# path to the module file where the tests you want to run are
TESTS_MODULE_PATH=./test/test_models.py
@gregorynicholas
gregorynicholas / index.html
Created March 19, 2012 17:34
De-obfuscated Code for Pinterest pinit button javascript: http://assets.pinterest.com/js/pinit.js
http://pinterest.com/pin/create/button/?url=http://www.domain.com&description=&media=
ex:
http://pinterest.com/pin/create/button/?url=http://www.youworkforthem.com&media=http://www.youworkforthem.com/img/eps/E1174/E1174_00.jpg&description=Escapism 30 pulls further away from reality by manipulating organic materials into beautiful, hi-res bursting textures. This is art, this is space, this is nature, this is chaos. Use as you wish.
@gregorynicholas
gregorynicholas / social.publisher.collection.js
Created March 20, 2012 17:15
publish a collection to thirdparty social networks
/*
* NOTES
*
* 1) NO event handlers, and logic based on DOM elements,
* rather, just write base code in a class-based format.
*
* 2) Add console logs and warnings for callback and server
* responses, be sure to log method args.
*
*/
function until_timeout(callback, deadline){
var interval = setInterval(function(){
if(callback()) {
clearInterval(interval);
}
}, deadline)
}
@gregorynicholas
gregorynicholas / jquery.tagsinput.js
Created April 2, 2012 22:56
jQuery Tags Input Plugin 1.3.3 - modified 2011-12-17
/*
* jQuery Tags Input Plugin 1.3.3
* http://xoxco.com/clickable/jquery-tags-input
*
* REFACTORED!! need to republish this to original author
* - Gregory Nicholas, 2012-02-17
*/
(function($) {
var delimiter = [];