Skip to content

Instantly share code, notes, and snippets.

View aezell's full-sized avatar
😶

Alex Ezell aezell

😶
View GitHub Profile
// init the storage object
var people = new Lawnchair('people');
// save an object
var me = {name: 'alex'};
people.save(me);
// what is the people object?
console.log(people)
@aezell
aezell / config.log
Created November 11, 2010 16:20
error when trying to install libvpx brew install
>>> brew install -vd libvpx
==> Build Environment
CC: /usr/bin/cc => /usr/bin/gcc-4.0
CXX: /usr/bin/c++ => /usr/bin/c++-4.0
LD: /usr/bin/cc => /usr/bin/gcc-4.0
CFLAGS: -O3 -march=nocona -mfpmath=sse -w -pipe
CXXFLAGS: -O3 -march=nocona -mfpmath=sse -w -pipe
MAKEFLAGS: -j2
==> Downloading http://webm.googlecode.com/files/libvpx-v0.9.2.tar.bz2
File already downloaded and cached to /Users/alex2/Library/Caches/Homebrew
@aezell
aezell / google_url.py
Created January 11, 2011 22:08
Messing around with goo.gl URL shortener API
import json, urllib2, pprint
"""
Mess around with goo.gl shortener API
"""
kind = "SHORTEN"
key = "YOUR_KEY"
api_url = "https://www.googleapis.com/urlshortener/v1/url?key=%s" % key
@aezell
aezell / sessions.php
Created February 2, 2011 21:09
DB-backed Cached Session Handling in PHP
<?php
class CachedSessionHandler {
private static $LOG_SESSION_ACTIVITY = false;
private static $binding;
private $cache;
private $read_sessions = array();
public static function bind($database)
@aezell
aezell / cached_db_session.py
Created February 2, 2011 21:13
DB-backed Cached Session in Python
from django.conf import settings
from django.contrib.sessions.backends.base import SessionBase
from django.core.cache import cache
from PHPSerialize import PHPSerialize
from PHPUnserialize import PHPUnserialize
from session_models import SessionEntry
from datetime import timedelta
from sqlalchemy import func, text
from sharding import Session
@aezell
aezell / hash_join.py
Created March 14, 2011 15:42
General hash_join function
def hash_join(left, right, join_key, attr_keys, outer=True):
"""
Allows you to join the keys/values from a list of dictionaries as the
attributes of a given list of objects.
Params::
- left - list of objects to join to
- right - list of dictionaries from which to get joined data
- join_key - attribute of both object and dictionary with which we can match
def render_data(self, obj):
if isinstance(obj,dict):
value = obj.get(self.id, None)
if not value and 'fields' in obj: # added
value = obj['fields'].get(self.id, None) # added
else:
value = getattr(obj,self.id, None)
if callable(value):
return self.format_data(value())
@aezell
aezell / datetime_safe.py
Created June 21, 2011 21:55
Django datetime
# Python's datetime strftime doesn't handle dates before 1900.
# These classes override date and datetime to support the formatting of a date
# through its full "proleptic Gregorian" date range.
#
# Based on code submitted to comp.lang.python by Andrew Dalke
#
# >>> datetime_safe.date(1850, 8, 2).strftime("%Y/%M/%d was a %A")
# '1850/08/02 was a Friday'
from datetime import date as real_date, datetime as real_datetime
@aezell
aezell / gitconfig.sh
Created June 26, 2012 14:52
Pruning Branches
[alias]
prunelocal = !sh -c 'git branch -d `git branch --merged | grep -v "^*"`'
pruneorigin = !sh -c 'git push origin `git branch -r --merged | grep \"^ origin/\" | grep -v "/master$" | sed "s/origin./:/g" | tr -d "\\n"`'
@aezell
aezell / sunset.txt
Created August 26, 2012 16:00
Shakespeare Plays and Sunset
python shakes.py -t 15:00:00 -a
Total Performances: 18
Candle Performances 16
Twilight Candle Performances 14
+--------------------------+-----------------------+-----------------------+-----------------------+-----------+-----------------------+--------------------+------------------+
| Play | Curtain Up | Sunset | Time Difference | Candles | Twilight Date | Twilight Candles | Sun's Altitude |
+--------------------------+-----------------------+-----------------------+-----------------------+-----------+-----------------------+--------------------+------------------+
| Henry VI, Part I | 1592/3/3 15:00:00 | 1592/3/3 17:50:08 | 2 hours, 50 minutes | Y | 1592/3/3 18:19:24 | N | 21:49:26.4 |
| Titus Andronicus | 1594/1/23 15:00:00 | 1594/1/23 16:40:13 | 1 hours, 40 minutes | Y | 1594/1/23 17:12:49 | Y | 10:20:11.3 |
| Taming of the Shrew |