Skip to content

Instantly share code, notes, and snippets.

View namongk's full-sized avatar

Tom namongk

View GitHub Profile
@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 = '-_~'
/* 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 "

Chef install isn't optimized yet for OS X 10.9 but there's a hacky way to get it installed.

First, download the install file at https://www.opscode.com/chef/install.sh

Then, edit the install.sh file and change this part:

    "10.6") platform_version="10.6" ;;
    "10.7") platform_version="10.7" ;;
 "10.8") platform_version="10.7" ;;
@namongk
namongk / install.sh
Created January 15, 2014 05:06 — forked from solar/install.sh
#!/bin/sh
version="2.6.3"
priority="20603"
sudo mkdir -p /var/redis /var/log/redis
curl -sL http://redis.googlecode.com/files/redis-${version}.tar.gz | tar zx
cd redis-${version}/
make
sudo make PREFIX=/usr/local/redis/${version} install
@namongk
namongk / korail.py
Created January 22, 2014 01:11 — forked from devxoul/korail.py
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
from datetime import datetime
session = requests.session()
class Train(object):
from fabric.api import env
env.use_ssh_config = True
env.forward_agent = True
env.roledefs = {
# key # hostname from config
'foo': ['foo.production'],
}