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
fp = open(msgfile) | |
msg = email.message_from_file(fp) | |
fp.close() | |
counter = 1 | |
for part in msg.walk(): | |
# multipart/* are just containers | |
if part.get_content_maintype() == 'multipart': | |
continue |
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
select array_to_string(array_agg(chr(a[s])),'') "I wish you" from ( | |
select a, generate_series(1,array_length(foo.a,1)) s from ( | |
select array[72,97,112,112,121,32,88,109,97,115,33] as a | |
) foo | |
) bar; |
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
// | |
// YamlNode helper | |
// author: mpenzin@gmail.com | |
// date: 2010-02-22 | |
// | |
package util; | |
import java.util.ArrayList; | |
import java.util.Collection; |
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 a flag to indicate the state of the bus. | |
class _StateEnum(object): | |
class State(object): | |
name = None | |
def __repr__(self): | |
return "states.%s" % self.name | |
def __setattr__(self, key, value): | |
if isinstance(value, self.State): |
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
import math | |
class ImmutableVector(object): | |
__slots__ = ('_d',) | |
def __init__(self, x, y): | |
object.__setattr__(self, _d, (x, y)) | |
def __setattr__(self, n, v): | |
raise ValueError("Can't alter instance of %s" % type(self)) | |
@property | |
def x(self): |
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
A basic FastCGI configuration for nginx looks like this: | |
location /yourapplication/ { | |
include fastcgi_params; | |
if ($uri ~ ^/yourapplication/(.*)?) { | |
set $path_url $1; | |
} | |
fastcgi_param PATH_INFO $path_url; | |
fastcgi_param SCRIPT_NAME /yourapplication; | |
fastcgi_pass unix:/tmp/yourapplication-fcgi.sock; |
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
# werkzeug.contrib | |
try: | |
import cPickle as pickle | |
except ImportError: | |
import pickle | |
import memcache | |
class MemcacheSessionStore(SessionStore): |
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
#!/bin/bash | |
grep -v \"Yandex/ |grep -v \"YaDirectBot/ |grep -v \"msnbot/ | grep -v Mediapartners-Google | grep -v Googlebot/ | \ | |
grep -v "Yahoo! Slurp" | grep -v \"LinkWalker | grep -v \"Python-urllib | grep -v \"StackRambler/ | grep -v \"Aport\" | \ | |
grep -v \"MLBot | grep -v \"Gigabot | grep -v \"COMODOSpider | grep -v \"ia_archiver | grep -v \"Java | \ | |
grep -v \"Begun\ Robot\ Crawler | grep -v MJ12bot/ | grep -v Mail.Ru/ | grep -v " (Twiceler-" | \ | |
grep -v \"Yangai\ WorldSearch\ Bot | grep -v \ DotBot/ | grep -v \ WebDataCentreBot/ | \ | |
grep -v \ TIC/ | grep -v \ spbot/ | grep -v \"Mail.Ru/ | grep -v \ Exabot/ | grep -v \ Nigma.ru/ | \ | |
grep -v \ Purebot/ |
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
[i+2 for i, numberList in enumerate([[i for x in range(2, i+1) if i % x == 0 and i != x] for i in range(2,100)]) if not numberList] |
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
#!/bin/env python | |
import memcache | |
import random | |
import time | |
mc = memcache.Client(["127.0.0.1:11211"]) | |
pc = {} | |
data = dict( a="abc", b=["def",123,('1','2')] ) |