Skip to content

Instantly share code, notes, and snippets.

View santa4nt's full-sized avatar
💭
😬

Santoso santa4nt

💭
😬
  • Los Angeles, CA
View GitHub Profile
@santa4nt
santa4nt / patch_basehttpserver.py
Created April 21, 2010 23:57
A patch for slow BaseHTTPServer's default handler.
# This is a hack to patch slow socket.getfqdn calls that
# BaseHTTPServer (and its subclasses) make.
# See: http://bugs.python.org/issue6085
# See: http://www.answermysearches.com/xmlrpc-server-slow-in-python-how-to-fix/2140/
import BaseHTTPServer
def _bare_address_string(self):
host, port = self.client_address[:2]
return str(host)
@santa4nt
santa4nt / .screenrc
Created April 22, 2010 01:52
My .screenrc configuration.
# .screenrc configuration
defscrollback 1024
# bind 'b' to copy to clipboard
bind b eval "writebuf" "exec sh -c 'pbcopy < /tmp/screen-exchange'"
# turn off start message
startup_message off
@santa4nt
santa4nt / .vimrc
Created April 22, 2010 01:52
My .vimrc configuration.
" .vimrc configuration
set nocompatible
set autoindent
set smartindent
set expandtab
set tabstop=4
set shiftwidth=4
set showmatch
set ruler
@santa4nt
santa4nt / Cygwin .Xdefaults configuration
Created June 2, 2010 17:47
Cygwin rxvt configurations
rxvt*title: Bash
rxvt*background: wheat
rxvt*foreground: black
rxvt*scrollBar_right: True
rxvt*colorBD: 1
rxvt*font: courier
rxvt*saveLines: 10000
rxvt*backspacekey: ^?
XTerm*saveLines: 5000
@santa4nt
santa4nt / youtube.py
Created June 2, 2010 19:09
A custom Django filter to embed a YouTube video from a URL.
import re
from django.template.defaultfilters import stringfilter
from django import template
register = template.Library()
YOUTUBE_RE = re.compile(r"^(http://)?(www\.)?(youtube\.com/watch\?v=)?(?P<id>[A-Za-z0-9\-=_]{11})")
YOUTUBE_EMBED = """
@santa4nt
santa4nt / getMMDDYYYY.bat
Created November 3, 2010 00:47
Parse the output of `DATE /T` and return it in MMDDYYYY format.
@echo off
:: sample usage
call:getMMDDYYYY _DATE
echo _DATE: %_DATE%
goto:eof
:: -----------------------------------------------------------------------------
:: The "function"
@santa4nt
santa4nt / DateAdd.bat
Created November 3, 2010 00:56
An DOS Batch script to add/subtract a number of days from the current date.
@ECHO OFF
ECHO.
:: Check the Windows version
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
SETLOCAL
:: Initialize variable
SET Error=0
@santa4nt
santa4nt / AdvanceDays.bat
Created November 3, 2010 01:42
Advance (or reverse) system clock a specified number of days.
@echo off
setlocal
set Error=0
if "%~1" == "" goto SYNTAX
if not "%~2" == "" goto SYNTAX
for %%A in (%DATE%) do set cDate=%%A
@santa4nt
santa4nt / Sleep.bat
Created November 3, 2010 20:58
A DOS script to "sleep" for a specified number of seconds.
call :sleep %~1
goto:eof
:: -----------------------------------------------------------------------------
:sleep
ping 127.1 -n 2 -w 1000 > NUL
ping 127.1 -n %~1 -w 1000 > NUL
goto:eof
@santa4nt
santa4nt / threadpool.py
Created November 11, 2010 01:39
A simple thread pool implementation.
# -*- coding: utf-8 -*-
"""A thread pool implementation.
Parts of this module are derived from:
http://code.activestate.com/recipes/203871-a-generic-programming-thread-pool/
"""
import time