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 smtplib | |
gmail_account = '[email protected]' | |
gmail_pass = 'misuperpass' | |
to_emails = ['[email protected]'] | |
message = """From: %s | |
To: %s | |
Subject: python rulz! |
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 | |
# Needs php and java in executable path | |
B64=""" | |
UEsDBBQAAAAIAIVyUjx/yWgsbQIAAP0CAAAHABwAcHJvYmxlbVVUCQADeTB9S3ow | |
fUt1eAsAAQToAwAABOgDAAAdUsmumlAA3fcrGtNFX1zABblgXm2jOACXSRBEY9Jc | |
5knmSb6+vi7OkJyzO+fXnx8T6W4WrB3LbiuOBxXMfNRNW8Wn9NipMa4QbVv8MQVL | |
05STYRfqADEysKpWFm/3mViqu5EtXlzGPVl6zauMly7vUNt3S9ji1LESwdn63jCN | |
DZkNHrzCc78lb8/mucZtFFM45ckrs1XnmtOYo34WENfnXkzC9vQ6s3sJEpCifalp | |
BtvFDjI50bJunpHhegTuhAKuKsh49uGhN9tXPJpkNxknpCaHjgoxivp4MNg4YQSG | |
V+K8IXs3KvSzK2IcaJOxvWny89ztEn66vIpYcNpw1jnkr7CplWUCGGNneZ0Y3mdK |
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 | |
# -*- coding: UTF-8 -*- | |
def getitem(l, index, default=None): | |
"""Returns value of index or default""" | |
try: | |
return l[index] | |
except IndexError: | |
return default |
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 tornado.httpserver | |
import tornado.ioloop | |
import tornado.options | |
import tornado.web | |
import tornado.wsgi | |
from tornado.options import define, options | |
define("port", default=8888, help="run on the given port", type=int) |
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
from random import choice | |
MALE_NAMES_FILE = 'dist.male.first' | |
FEMALE_NAMES_FILE = 'dist.female.first' | |
LAST_NAMES_FILE = 'dist.all.last' | |
if __name__ == '__main__': | |
MALE_NAMES = list(line.split()[0] for line in open(MALE_NAMES_FILE)) | |
FEMALE_NAMES = list(line.split()[0] for line in open(FEMALE_NAMES_FILE)) | |
LAST_NAMES = list(line.split()[0] for line in open(LAST_NAMES_FILE)) |
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
from __future__ import with_statement # python2.5 | |
""" | |
Project root holds virtual environment | |
""" | |
from fabric.api import * | |
import os.path | |
# globals | |
env.project_name = 'myproject' |
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
SetHandler python-program | |
PythonHandler django.core.handlers.modpython | |
SetEnv DJANGO_SETTINGS_MODULE myproject.settings | |
PythonDebug On | |
PythonPAth "['/home/darkrho/django_sites'] + sys.path" | |
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
# Django settings for myproject project. | |
import os | |
import sys | |
DEBUG = True | |
TEMPLATE_DEBUG = DEBUG | |
ADMINS = ( | |
# ('Your Name', '[email protected]'), | |
) |
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
cookies = {} | |
for cs in response.headers['set-cookie'].split(';'): | |
data = cs.split('=') | |
cookies[data[0]] = data[1] if len(data) > 1 else data[0] | |
sessid = cookies['PHPSESSID'] |
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
from scrapy.core import signals | |
from scrapy import log | |
from scrapy.xlib.pydispatch import dispatcher | |
import time | |
class ElapsedTimeMiddleware(object): | |
def __init__(self): | |
self._registry = {} | |
dispatcher.connect(self.spider_opened, signal=signals.spider_opened) |