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 / 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
@gregorynicholas
gregorynicholas / gist:2920788
Created June 12, 2012 23:26 — forked from johnkpaul/gist:2361303
gruntjs Mocha task
/*
* grunt
* https://github.com/cowboy/grunt
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Copyright (c) 2012 John K. Paul @johnkpaul
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
@gregorynicholas
gregorynicholas / Makefile
Created June 15, 2012 15:41 — forked from mdornseif/Makefile
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 / dbextras.py
Created June 15, 2012 15:41 — forked from csytan/dbextras.py
appengine db extras
from google.appengine.ext import db
from django.utils import simplejson
### Functions ###
def fetch_references(entities, attr):
"""Fetches and sets ReferenceProperty attributes in one db call"""
keys = []
for entity in entities:
key = getattr(entity, '_' + attr)
@gregorynicholas
gregorynicholas / console.py
Created June 15, 2012 15:41 — forked from chrisfarms/console.py
An appengine python console
#!/usr/bin/env python
import getopt
import os
import ae
import sys
import code
def usage():
print """
import logging
from google.appengine.api import memcache
from google.appengine.api import apiproxy_stub_map
from google.appengine.datastore import datastore_pb
"""Provides a shim that caches datastore Get calls.
Example code:
import datastore_get_cache
@gregorynicholas
gregorynicholas / fb_pinterest.js
Created August 7, 2012 21:09
How Pinterest invite facebook friends.
$(document).ready(function() {
function sendInvites(fb_ids, selector) {
var link_url = "http://pinterest.com/invited/?code=41165921502368484";
FB.ui({
method: "send",
to: fb_ids,
name: "Join Pinterest, the Virtual Pinboard",
description: "Pinterest lets you organize and share all the beautiful things you find on the web. People use pinboards to plan their weddings, decorate their homes, and organize their favorite recipes.",
picture: "http://media-cache0.pinterest.com//images/favicon_red_250.png",
link: link_url
@gregorynicholas
gregorynicholas / generateRandomKey.js
Created August 24, 2012 17:50 — forked from prcaen/generateRandomKey.js
[JS] - generateRandomKey
function generateRandomKey(size)
{
var keyset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$.+-_$';
var result = [];
for (var i = 0; i < size; i++) {
// todo: Math.random has issues and baggage: http://stackoverflow.com/questions/424292/how-to-create-my-own-javascript-random-number-generator-that-i-can-also-set-the
var rnum = Math.floor(Math.random() * keyset.length);
result[i] = keyset.substring(rnum, rnum + 1);
}
return result.join('');
#!/usr/bin/env bash
openssl genrsa -out key.pem 2048
openssl req -new -config request.cnf -x509 -key key.pem -out cert.pem -days 1095
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]