Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
@mdornseif
mdornseif / Makefile
Created January 12, 2011 23:25
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`
@ryankirkman
ryankirkman / auth_to_expressjs_with_curl.sh
Created March 29, 2011 08:43
How to authenticate to an express.js web service with curl
#!/bin/sh
## Save cookies to the "cookies.txt" file
## Assumes the web service expects username
## and password in a JSON object, submitted via POST.
curl --cookie-jar cookies.txt -H "Content-Type: application/json" -X POST http://localhost:3000/user/login -d "{\"username\": \"YOURUSERNAME\", \"password\": \"YOURPASSWORD\"}"
## Now to use the authenticated session:
## (Assuming your web service speaks JSON)
curl --cookie cookies.txt -X GET http://localhost:3000/user/SOMEID
@solsolomon
solsolomon / module.js
Created May 3, 2011 20:29
module pattern stub
var stub = function (settings) {
var _settings = {
$container: $('#container')
};
if (settings) {
$.extend(_settings, settings);
}
_returnObject = {
@amrnt
amrnt / rails.validations.js.coffee
Created May 6, 2011 16:13
Rails 3 Client Side Validations - CoffeeScript
###
* Rails 3 Client Side Validations - v3.0.4
* https://github.com/bcardarlela/client_side_validations
*
* Copyright (c) 2011 Brian Cardarella
* Licensed under the MIT license
* http://www.opensource.org/licenses/mit-license.php
*
* CoffeeScript Version is by Amr Numan Tamimi - v3.0.4.CoffeeScript
###
@soffes
soffes / blame.rb
Created May 12, 2011 17:31
Find the number of lines of code per person in a repository
# Put this file in the root of your git repository then run `ruby blame.rb`.
# You will need gsed. You can install gsed with `brew install gsed`.
# Crazy shell script taken from http://stackoverflow.com/questions/4589731/git-blame-statistics
input = `git ls-tree -r HEAD|gsed -re 's/^.{53}//'|while read filename; do file "$filename"; done|grep -E ': .*text'|gsed -r -e 's/: .*//'|while read filename; do git blame "$filename"; done|gsed -r -e 's/.*\\((.*)[0-9]{4}-[0-9]{2}-[0-9]{2} .*/\\1/' -e 's/ +$//'|sort|uniq -c`
aggregated = {}
input.lines.each do |line|
line.strip!
@kylefinley
kylefinley / gist:1025736
Created June 14, 2011 19:59
AppEngine ndb Threaded Messaging.
import cgi
from google.appengine.api import mail
from google.appengine.ext import deferred
from ndb import model
from tipfy.routing import url_for
from tipfyext.ndb.mixins import DateMixin
@jgeewax
jgeewax / anagram.py
Created June 18, 2011 21:41
Anagram data structure
from collections import defaultdict
words = ['eat', 'tea', 'ate', 'time'] # ... get words from somewhere else
data = defaultdict(set)
for word in words:
data[''.join(sorted(word))].add(word)
def get_anagrams_for(word):
words = data[''.join(sorted(word))]
@pamelafox
pamelafox / usermodel.py
Created July 6, 2011 21:08
SimpleGeo Timezone Calculation on Python App Engine
class User(db.Model):
location = db.StringProperty()
timezone = db.StringProperty(default='America/Los_Angeles')
# Do this once per user
def calculate_timezone(self):
from simplegeo import Client
client = Client('oauth key', 'oauth secret SHH')
response = client.context.get_context_by_address(self.location)
for feature in response['features']:
@TooTallNate
TooTallNate / mixpanel.js
Created August 8, 2011 22:38
Mixpanel JS Lib, Beautified
var MixpanelLib = function (j, n, m) {
function k(a, c, b) {
if (a.length) {
var e;
for (e = 0; e < a.length; e++) c.call(b || c, a[e], e)
} else if (typeof a == "object") for (e in a) Object.hasOwnProperty.call(a, e) && c.call(b || c, a[e], e)
}
function z(a, c) {
a.prototype = new c;
a.prototype.constructor = a;
@chrisfarms
chrisfarms / ae.py
Created August 10, 2011 14:37
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/"