Skip to content

Instantly share code, notes, and snippets.

View sgammon's full-sized avatar
:shipit:
f*ck it, ship it

Sam Gammon sgammon

:shipit:
f*ck it, ship it
View GitHub Profile
@sgammon
sgammon / search.php
Created July 24, 2011 00:39
Hampshire Connect help: search function
<?php
include("mainstyle.php");
include("links.php");
mysql_connect ("localhost", "db","password") or die (mysql_error());
mysql_select_db ("db");
$term = $_POST['term'];
//$sql = mysql_query("SELECT 'firstname','lastname' FROM users WHERE
MATCH('firstname','lastname') AGAINST('%$term%')");
## Input - can be any length
input = 1234567890
## Turn into a list of the input's digits (input should now be [1,2,3, n...])
input = [int(i) for i in list(str(input))]
## 1: Generate index pairs that need to be added (i.e. [(0, 1), (1, 2), n...]). Chop off last input digit.
## 2: Once we have a list of index int tuples, add the two spots in the input number corresponding to those indexes (i, i+1).
## 3: Once we have a list of the added digit pairs, add those from left to right.
@sgammon
sgammon / datastructures.py
Created October 28, 2011 08:39
Experiments with Python datastructures
## Sample data
simplelist = [1, 2, 3, 4, 5]
listsample = ['Sam', 'Tyler', 'David', 'AJ']
people = [('Sam', 'Gammon'), ('Tyler', 'Porras'), ('David', 'Rekow'), ('Jackson', 'Harris')]
merchandise = {
'tshirts': ('SurviveSac T-Shirt', {'price': 5.99, 'orders': 15, 'options': ['small', 'large', 'xlarge']}),
'map': ('Field of Play Map', {'price': 3.0, 'orders': 28}),
'tickets': ('Ticket to Play', {'price': 5.0, 'orders': 1428})
@sgammon
sgammon / mappers.py
Created November 7, 2011 19:59
Example map/reduce mapper fn
import os
import logging
from mapreduce import context
from mapreduce import shuffler
from mapreduce import operation
from mapreduce import mapreduce_pipeline
from google.appengine.ext import db
from google.appengine.api import files
from google.appengine.ext import blobstore
@sgammon
sgammon / momentum-sublime-packages.json
Created January 16, 2012 21:25
Describes endpoints for custom Sublime addons built by momentum.
{
"schema_version": "1.1",
"packages": [
{
"name": "AppTools for Sublime",
"description": "Run tools in AppEngine Toolkit directly from Sublime.",
"author": "Sam Gammon (sgammon)",
"homepage": "http://apptools.github.com/integration/sublime",
"last_modified": "2012-01-16 13:30:00",
"platforms": {
(function($) {
var config, cfg,
options,
methods = {
init : function(options) {
config = $.extend({
(function($, window, document, undefined) {
// Feature tests shamelessly borrowed from Modernizr... unless Modernizr is available, in which case it is used
window._featureTests = {};
prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
omPrefixes = 'Webkit Moz O ms';
cssomPrefixes = omPrefixes.split(' ');
domPrefixes = omPrefixes.toLowerCase().split(' ');
@sgammon
sgammon / Cakefile
Created March 26, 2012 22:16
momentum.io's cool ass cakefile
fs = require 'fs'
path = require 'path'
util = require 'util'
wrench = require 'wrench'
{exec, spawn} = require 'child_process'
fixpath = (fragments...) =>
return path.normalize(path.join(fragments...))
defaults =
@sgammon
sgammon / content.py
Created March 26, 2012 23:01
cms message structures
from protorpc import messages
class GetContentRequest(messages.Message):
''' Retrieve a content snippet. '''
snippet_key = messages.StringField(1)
snippet_keyname = messages.StringField(2)
@sgammon
sgammon / bootstrap.py
Created March 26, 2012 23:08
the magic fix for the dev server's bullshit
import sys
if 'lib' not in sys.path:
# Add lib as primary libraries directory, with fallback to lib/dist
# and optionally to lib/dist.zip, loaded using zipimport.
sys.path[0:0] = ['lib', 'lib/dist', 'lib/dist.zip']
class AppBootstrapper(object):