Skip to content

Instantly share code, notes, and snippets.

@teeler
teeler / gist:3751961
Created September 19, 2012 20:15
Simple backbone.js handler for GAE
import json
import logging
from google.appengine.ext import db
from google.appengine.api import users
import webapp2
# With routes like:
#app = webapp2.WSGIApplication([
# webapp2.Route("/d/<collection>", DataHandler, methods=["GET", "POST"]),
# webapp2.Route("/d/<collection>/<id>", DataHandler, methods=["GET", "PUT", "DELETE"]),
@teeler
teeler / lefty.py
Created July 13, 2012 01:40
Left handed passwords
# Generate passwords of length suitable for typing with just your left hand.
import os, random, string
length = 10
chars = "12345qwertasdfgzxcvQWERT!@#$%ASDFGZXCV"
random.seed = (os.urandom(1024))
print ''.join(random.choice(chars) for i in range(length))
@teeler
teeler / synapyse.py
Created July 12, 2012 01:13
synapse python client
import base64
import hashlib
import hmac
import jsonlib2
import requests
import sys
import time
class SynapseLoginException(Exception):
@teeler
teeler / index.js
Created May 9, 2012 03:10 — forked from kconragan/index.js
list surf sessions
exports.listLogs = function(req, res) {
SurfSession.find()
.populate('location')
.run(function(err, log) {
Wave.find(function(err, waves) {
var surfHeight = SurfSession.schema.path('surfHeight').enumValues;
var surfConditions = SurfSession.schema.path('surfConditions').enumValues;
var surfStoke = new SurfSession().generateStoke();
var currentYear = moment().year();
var surfSessionsThisYear = 0;
@teeler
teeler / gist:2411377
Created April 18, 2012 05:58
without bullshit
var request = require("request")
var parseBuoyData(buoyid, cb) {
request(buoyURL(buoyid), function(e, r, b) {
if (e) {
throw new Error(e)
}
// do all that insane parsing nonsense here
// Takes NDBC Buoy ID, and returns
// series of readings
// Just to generate a URL.
var BuoyURL = function(buoyId) {
return 'http://www.ndbc.noaa.gov/data/5day2/' + buoyId + '_5day.txt';
};
exports.parseBuoyData = function(buoy) {
var moment = require('moment');
var request = require('request');
exports.formatDate = function(format, date) {
};
// Takes NDBC Buoy ID, and returns
// series of readings
var fetchBuoy = function(buoyId) {
request('http://www.ndbc.noaa.gov/data/5day2/' + buoyId + '_5day.txt', function(err, response, body){
@teeler
teeler / wtf.R
Created March 14, 2012 20:06
R WTF
# Ok, so appending items to lists.
# I'm fine with this.
f <- list()
f <- c(f, 1)
f <- c(f, 2)
f <- c(f, 3)
# Ok, lets try something fancier, lists of lists.
library(doRedis)
registerDoRedis()
library(doRedis)