This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 '$.store.book[0].category' | |
// fiction | |
var stdin = process.stdin, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Use setattr | |
""" | |
# Normal | |
item.price = self.request['price'] | |
item.quantity = self.request['quantity'] | |
item.shipping = self.request['shipping'] | |
item.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 | |
k+=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<appender name="STDOUT2" class="ch.qos.logback.core.ConsoleAppender"> | |
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |
<level>TRACE</level> | |
<OnMatch>NEUTRAL</OnMatch> | |
<OnMismatch>DENY</OnMismatch> | |
</filter> | |
<layout class="ch.qos.logback.classic.PatternLayout"> | |
<Pattern>STDOUT1 %logger{36} - %msg%n</Pattern> | |
</layout> | |
</appender> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
See also: | |
- http://code.activestate.com/recipes/52549/#c6 | |
- http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application | |
""" | |
class curry: | |
def __init__(self, fun): | |
import inspect | |
self.fun = fun |