Skip to content

Instantly share code, notes, and snippets.

View timtrueman's full-sized avatar

Tim Trueman timtrueman

View GitHub Profile
@xingrz
xingrz / RealmAdapter.java
Last active May 22, 2020 19:46
A RecyclerView.Adapter-like Adapter that binds RealmResults to ListView
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import io.realm.RealmObject;
import io.realm.RealmResults;
public abstract class RealmAdapter<E extends RealmObject, VH extends RealmAdapter.ViewHolder>
extends BaseAdapter {
@zacharyvoase
zacharyvoase / pythonrc.py
Created May 4, 2011 13:31 — forked from benhodgson/pythonrc.py
Python startup file with completion, history and colored source browsing.
import inspect
import sys
def src(obj):
"""Read the source of an object in the interpreter."""
def highlight(source):
try:
import pygments
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
high quality greens: http://www.hibiki-an.com/
https://shop.ippodo-tea.co.jp/shop/en/
http://www.teaforte.com/
sencha (Japanese green), and Assam (Indian black).
http://www.omshantea.com/ -- A cool tea house in SF (mission). Learn about Pu-erh and Jiaogulan here.
http://www.teaspring.com/ -- Chinese Tea.
@jdmaturen
jdmaturen / worker3.py
Created January 25, 2011 03:42
Redis stats aggregator w/ Gevent
import gevent
from gevent import monkey
monkey.patch_socket()
import hashlib
import os
import redis
from django.http import HttpRequest
class PickleableHttpRequest(HttpRequest):
def __init__(self, request=None, attributes=None):
super(PickleableHttpRequest, self).__init__()
if request:
if not isinstance(request, HttpRequest):
raise Exception('Request supplied is not a valid HTTP request object.')
!function() {
var doc = document,
htm = doc.documentElement,
lct = null, // last click target
nearest = function(elm, tag) {
while (elm && elm.nodeName != tag) {
elm = elm.parentNode;
}
return elm;
};
@onyxfish
onyxfish / fabfile.py
Created February 9, 2010 23:05
Chicago Tribune News Applications fabric deployment script
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"