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
# method 1 | |
import ctypes | |
obj = ctypes.cast(id(orig_obj), ctypes.py_object).value | |
# method 2 | |
import gc | |
for obj in gc.get_objects(): | |
if id(obj) == id_: | |
yield obj | |
else: |
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
# https://github.com/scraperwiki/pdfminer/blob/scraperwiki/tools/pdf2html.cgi | |
import pdfminer | |
from pdfminer.pdfinterp import PDFResourceManager, process_pdf | |
from pdfminer.converter import HTMLConverter, TextConverter | |
from pdfminer.layout import LAParams | |
rsrcmgr = PDFResourceManager() | |
laparams = LAParams() | |
converter = HTMLConverter if format == 'html' else TextConverter | |
device = converter(rsrcmgr, out_file, codec='utf-8', laparams=laparams) | |
process_pdf(rsrcmgr, device, in_file, pagenos=[1,3,5], maxpages=9) |
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
schtasks /Create /SC HOURLY {DAILY,WEEKLY} /TN My_Task /TR "C:\python27\python.exe C:\dir\task1.py" |
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 re | |
import random | |
import base64 | |
from scrapy import log | |
class RandomProxy(object): | |
def __init__(self, settings): | |
self.proxy_list = settings.get('PROXY_LIST') | |
fin = open(self.proxy_list) |
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
wordlist = (w.strip() for f in wordlistfiles for w in open(f)) |
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
# lookup optimizations (ugly but fast) | |
queue = collections.deque() | |
queue_append, queue_popleft = queue.append, queue.popleft | |
queue_appendleft, queue_pop = queue.appendleft, queue.pop |
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
# general docs: | |
# https://docs.python.org/2/library/_winreg.html#module-_winreg | |
# usage example: | |
# http://www.blog.pythonlibrary.org/2010/03/20/pythons-_winreg-editing-the-windows-registry/ | |
# reading | |
from _winreg import * | |
key = OpenKey(HKEY_LOCAL_MACHINE, r'Software\Microsoft\Outlook Express', 0, KEY_ALL_ACCESS) | |
QueryValueEx(key, "InstallRoot") |
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
[program:tornado] | |
environment=PATH="/home/vanko/.virtualenvs/env1/bin" | |
command=/home/vanko/.virtualenvs/env1/bin/python /home/vanko/app1/app.py --port=%(process_num)s |
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
# supervisord service for sysstemd (CentOS 7.0+) | |
# by ET-CS (https://github.com/ET-CS) | |
[Unit] | |
Description=Supervisor daemon | |
[Exec] | |
User=vanko | |
WorkDir=/home/vanko | |
[Service] |
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 crontab import CronTab | |
from datetime import datetime, timedelta | |
import time | |
import os | |
import xmlrpclib | |
import urlparse | |
import logging | |
import json | |
import shlex |
OlderNewer