Skip to content

Instantly share code, notes, and snippets.

View garrydzeng's full-sized avatar

Octobrain garrydzeng

  • Xiamen, Fujian, China
  • 12:14 (UTC +08:00)
View GitHub Profile
@garrydzeng
garrydzeng / database_factory.py
Last active August 29, 2015 14:03
Database factory for DBAPI 2.0
import configparser
class DatabaseFactory(object):
def __init__(self, filename, encoding=None):
"""instantiate with configuration filename"""
self._cache = dict()
self._servers = configparser.ConfigParser()
self._servers.read(filename, encoding)
@garrydzeng
garrydzeng / event.js
Created July 12, 2013 07:49
JavaScript addEvent, written by Dean Edwards
// written by Dean Edwards, 2005
// with input from Tino Zijdel, Matthias Miller, Diego Perini
// http://dean.edwards.name/weblog/2005/10/add-event/
function addEvent(element, type, handler) {
if (element.addEventListener) {
element.addEventListener(type, handler, false);
} else {
// assign each event handler a unique ID
@garrydzeng
garrydzeng / CodeTimer.cs
Last active May 24, 2016 04:58
Simple C# Code Timer by JeffreyZhao
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
public static class CodeTimer
{
public static void Initialize()
{
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;