Skip to content

Instantly share code, notes, and snippets.

View namongk's full-sized avatar

Tom namongk

View GitHub Profile
from fabric.api import env
env.use_ssh_config = True
env.forward_agent = True
env.roledefs = {
# key # hostname from config
'foo': ['foo.production'],
}
@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:
{
"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/",
@namongk
namongk / log.py
Last active December 11, 2015 09:18
# models.py
from django.db import models
class BusinessLog(models.Model):
STATUS = (('ING', 'Ongoing'),
('DONE', 'Done'))
status = models.CharField(choices=STATUS, default='ING')
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
#-*-coding:utf-8-*-
import re
import unicodedata
from django.utils.encoding import smart_unicode
# Extra characters outside of alphanumerics that we'll allow.
SLUG_OK = '-_~'