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
class ConnectionPool(): | |
""" | |
Usage: | |
conn_pool = nmi_mysql.ConnectionPool(config) | |
db = conn_pool.get_connection() | |
db.query('SELECT 1', []) | |
conn_pool.return_connection(db) | |
conn_pool.close() |
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
class Timeit(object): | |
def __init__(self, tag): | |
self.tag = tag | |
def __enter__(self): | |
self.start = time.time() | |
def __exit__(self, *unused): | |
self.cost = time.time() - self.start |
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 | |
""" | |
This script scans the current working directory for changes to .go files and | |
runs `go test` in each folder where *_test.go files are found. It does this | |
indefinitely or until a KeyboardInterrupt is raised (<Ctrl+c>). This script | |
passes the verbosity command line argument (-v) to `go test`. | |
""" | |
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
{"tags":[],"lastModified":1517888208508} |
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 use the first | |
—– BEGIN LICENSE —– | |
Michael Barnes | |
Single User License | |
EA7E-821385 | |
8A353C41 872A0D5C DF9B2950 AFF6F667 | |
C458EA6D 8EA3C286 98D1D650 131A97AB | |
AA919AEC EF20E143 B361B1E7 4C8B7F04 |
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=utf8 | |
# author=evi1m0 | |
# website=linux.im | |
''' | |
12306 Captcha Picture: | |
author: Evi1m0@20150316 | |
1. Download Captcha | |
2. Pic Conver Text |
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
Felix Krull runs a PPA offering basically any version of Python (seriously, there is 2.3.7 build for vivid...) for many Ubuntu releases at | |
https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes | |
Do the usual: | |
sudo add-apt-repository ppa:fkrull/deadsnakes | |
sudo apt-get update | |
sudo apt-get install python3.5 | |
It will not overwrite your existing python3.4 which is still symlinked as python3. If you want python3.5 to be the default python3, change the symlink |
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/578150-sending-non-ascii-emails-from-python-3/ | |
import os | |
import smtplib | |
from email.utils import formataddr | |
from email.utils import formatdate | |
from email.utils import COMMASPACE | |
from email.header import Header |
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
# -*- coding: utf-8 -*- | |
import Image | |
def resize_and_crop(img_path, modified_path, size, crop_type='top'): | |
""" | |
Resize and crop an image to fit the specified size. | |
args: | |
img_path: path for the image to resize. |
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 | |
from getpass import getpass | |
def prompt(prompt): | |
return input(prompt).strip() | |
fromaddr = prompt("From: ") | |
toaddrs = prompt("To: ").split() | |
subject = prompt("Subject: ") | |
print("Enter message, end with ^D (Unix) or ^Z (Windows):") |