Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
$counter = 0;
$curr = $("#start");
$curr.css("-webkit-transform", "translate3d(0,0,0)");
$curr.css("-moz-transform", "translate(0,0)");
$curr.append("<div><img src='" + image[$counter] + "'></div>");
$counter = 1;
$currnext = $curr.next();
@gregorynicholas
gregorynicholas / .profile
Created February 2, 2012 18:38
Configure default shell python interpreter to load google appengine SDK on OSX
# python
export PYTHONDONTWRITEBYTECODE=1
export PYTHONSTARTUP="~/.pythonrc"
@gregorynicholas
gregorynicholas / gae
Created February 8, 2012 08:23
google appengine dev_appserver.py start command
set -e
GAELIBROOT="/usr/local/google_appengine/"
PORT=80
ADDRESS=127.0.0.1
# custom paths for where to store data
DATA=$ROOT/$ID/data
LOGS=$ROOT/$ID/logs
SRC=$ROOT/$ID/src
@gregorynicholas
gregorynicholas / shopify_stats.v3.js
Created February 9, 2012 12:43
shopify_stats.v3.js
(function() {
var engines = [
['Google', 'q', /\.google\./ ],
['Yahoo!', 'p', /search\.yahoo\./ ],
['MSN', 'q', /\.msn\./ ],
['Live', 'q', /\.live\./ ],
['AlltheWeb', 'q', /\.alltheweb\./ ],
['AOL', 'query', /\.aol\./ ],
['Ask', 'q', /\.ask\./ ],
['AltaVista', 'q', /\.altavista\./ ],
var _gauges = _gauges || [];
(function () {
var h = (_gauges['slice']) ? _gauges.slice(0) : [];
_gauges = {
track_referrer: true,
image: new Image(),
track: function () {
this.setCookie('_gauges_cookie', 1, 1);
var a = this.url();
if (a) {
@gregorynicholas
gregorynicholas / bundle_pin_50a7c889.js
Created February 10, 2012 21:42
pinterest google analytics tracking events
trackGAEvent("pin", "clicked", "add_dialogue");
trackGAEvent("pin", "success", "add_dialogue");
trackGAEvent("rearrange_board_save", "clicked");
trackGAEvent("rearrange_board_save", "success");
trackGAEvent("send_message", "clicked");
trackGAEvent("send_message", "success");
trackGAEvent("follow_board", "clicked");
@gregorynicholas
gregorynicholas / .inputrc
Last active April 19, 2024 04:10
OSX .inputrc to make terminal way better. and by better i mean i'm naked
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
@gregorynicholas
gregorynicholas / nose_tests
Created February 27, 2012 02:33
Command for the NOSE test runner
#
# variable for the root folder for the project, expected that "src" dir
# sites underneath the root.
#
# ex: APPROOT=/users/<username>/sites/<projectname>
#
APPROOT=''
nosetests \
--config=$APPROOT/.noserc \
@gregorynicholas
gregorynicholas / failsafe_datastore_put.py
Created February 28, 2012 15:38
Fail-safe datastore updates on app engine
import logging
from google.appengine.api.labs.taskqueue import taskqueue
from google.appengine.datastore import entity_pb
from google.appengine.ext import db
from google.appengine.runtime.apiproxy_errors import CapabilityDisabledError
def put_failsafe(e, db_put_deadline=20, retry_countdown=60, queue_name='default'):
"""Tries to e.put(). On success, 1 is returned. If this raises a db.Error
or CapabilityDisabledError, then a task will be enqueued to try to put the
entity (the task will execute after retry_countdown seconds) and 2 will be
@gregorynicholas
gregorynicholas / versioned_model.py
Created February 28, 2012 18:36
shallow copy app engine model instance to create new instance
class VersionedModel(BaseModel):
is_history_copy = db.BooleanProperty(default=False)
version = db.IntegerProperty()
created = db.DateTimeProperty(auto_now_add=True)
edited = db.DateTimeProperty()
user = db.UserProperty(auto_current_user=True)
def put(self, **kwargs):
if self.is_history_copy:
if self.is_saved():