This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stub = function (settings) { | |
var _settings = { | |
$container: $('#container') | |
}; | |
if (settings) { | |
$.extend(_settings, settings); | |
} | |
_returnObject = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
* 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 | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################### | |
# 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/" |