Skip to content

Instantly share code, notes, and snippets.

View saml's full-sized avatar

Sam Lee saml

  • New York, NY
View GitHub Profile
<VirtualHost *:80>
RewriteEngine On
RewriteMap lowercase int:tolower
# if already rewitten and we have the right path, stop right here
#RewriteCond /var/www/vhosts/${lowercase:%{SERVER_NAME}/htdocs} !-d
#RewriteRule ^/(.*)$ /var/www/vhosts/_default/htdocs/$1 [L,E=VHOST_ROOT:/var/www/vhosts/_default/htdocs]
RewriteRule ^(/var/www/vhosts/[^/]+/.*)$ $1
"""A little script to recover deleted recording of a mongoDB db file
There's no optimization but it work and has saved me
"""
import struct
import bson
import sys
  1. Dining philosopher

They want food so they wait. And end up eating each other.

  1. Given a random number generator that returns a number between [0,1], how would you build a RNG that accounted for weighting?

WAT?

  1. You have two arrays with N integers in them. Merge those arrays using a recursive algorithm so that the integers in the final array are sorted.

Twitter公式クライアントのコンシューマキー

Twitter for iPhone

Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU

Twitter for Android

Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPad

Consumer key: CjulERsDeqhhjSme66ECg

import sys
sys.setrecursionlimit(999999999)
class Solver(object):
def __init__(self, coins):
self.coins = coins
self.path = {}
self.memo = {}
def cost(self, cents):
if cents == 0:
@saml
saml / start-jnpr-vpn.sh
Created August 3, 2012 11:10 — forked from oogali/start-jnpr-vpn.sh
Shell script to connect to Juniper SSL VPNs w/o need for a browser or Java
#!/bin/sh
##
## netscreen/jnpr ssl vpn connection magic
## oogali@idlepattern.com / @oogali
##
## i wrote this about a year ago (2009), when i had continuous access
## to a jnpr ssl vpn box and had to connect via it.
##
## if bits of this script are broken, i'll be glad to fix if someone
## gives me client access to a ssl vpn box to test against.
@saml
saml / gist:1165067
Created August 23, 2011 13:15 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: Day CQ Enterprise Java Content Management System Expert and Adobe Technology Evangelist
Favorite Python project: pypy
Favorite Conference: icfp
Python Experience Level: web scaling in the cloud