Skip to content

Instantly share code, notes, and snippets.

View namongk's full-sized avatar

Tom namongk

View GitHub Profile
@namongk
namongk / fabric.py
Created February 19, 2014 12:27 — forked from adeleinr/fabric.py
"""
Distributor ID: Ubuntu
Description: Ubuntu 10.04 LTS
Release: 10.04
Codename: lucid
Author: Adelein Rodriguez, adeleinr@gmail.com
Note: This is an adaptation from a fabric script presented here:
http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p.html
Summary: This script:
from fabric.api import env
env.use_ssh_config = True
env.forward_agent = True
env.roledefs = {
# key # hostname from config
'foo': ['foo.production'],
}
{
"directory": "src/_lib",
"json": "bower.json"
}
class ThriftConnection(object):
def __init__(self, service, host, port):
socket = TSocket.TSocket(host, port)
self.transport = TTransport.TFramedTransport(socket)
protocol = TBinaryProtocolAccelerated(self.transport)
self.client = service.Client(protocol)
self.transport.open()
self.open_time = time.time()
self.access_time = self.open_time
self.pid = os.getpid()
import unittest
import functools
def check(sub, sup):
try:
if len(sub) == 1 and sup.index(sub[0]) >= 0:
return True
return check(sub[1:], sup[sup.index(sub[0]) + 1:])
except:
return False
from flask import Flask, request, session, g, redirect, url_for
from flask import abort, render_template, flash
app = Flask(__name__)
app.config.from_object(__name__)
hosts = {
'b': "https://code.google.com/p/android/issues/"
's': "https://android.googlesource.com/",
'r': "https://android-review.googlesource.com/",
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(
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
/* Border & Vignette Setup */
figure{
position: relative;
display: block;
line-height: 0;
width: 500px;
height: 333px;
margin-bottom: 2em;
border: 1em solid #fff;
import sys
import logging
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = ("Invalidates portions of the queryset cache based on the app names"
" or models provided as arguments to the command. If no arguments "
"are provided, nothing is done. To clear the entire queryset "