Skip to content

Instantly share code, notes, and snippets.

rctay /
Created Dec 19, 2015 — forked from UniIsland/
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
View jsonpath.js
#!/usr/bin/env node
// Reads JSON from stdin, and runs a JSONPath expression from the command-line on it.
// eg.
// $ npm install # install dependencies
// $ echo '{"store": {"book":[{"category":"fiction"}]}}' | node jsonpath.js '$[0].category'
// fiction
var stdin = process.stdin,
rctay /
Created Nov 14, 2012 — forked from geeknam/
Python refactors
Use setattr
# Normal
item.price = self.request['price']
item.quantity = self.request['quantity']
item.shipping = self.request['shipping']
rctay /
Created Nov 17, 2011 — forked from ejamesc/gist:1373187
[fork] Sieve
"""Translated from Haskell:
let sieve(p:xs) = p : sieve (filter (\ x -> x `mod` p /= 0) xs) in sieve [2..]
from itertools import ifilter
def ints(k):
while True:
yield k
rctay / bashrc
Created Nov 14, 2011 — forked from shawntan/bashrc
[fork] my .bashrc
View bashrc
# /etc/bash/bashrc
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
rctay / appender3.xml
Created Nov 2, 2011 — forked from iwein/appender3.xml
[fork] Appender filtering particular trace logging
View appender3.xml
<appender name="STDOUT2" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>STDOUT1 %logger{36} - %msg%n</Pattern>
View gist:1226563
See also:
class curry:
def __init__(self, fun):
import inspect = fun