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 sys | |
import itertools | |
import csv | |
def grouper(n, iterable, fillvalue=None): | |
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" | |
args = [iter(iterable)] * n | |
return itertools.izip_longest(fillvalue=fillvalue, *args) | |
def chainfix(lines): |
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 sys | |
import os | |
from datetime import datetime | |
from PIL import Image | |
# Keys of items that may contain date | |
items = [36868, 36867, 306] | |
# Output date format |
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 sys | |
import os | |
import glob | |
import subprocess | |
import tempfile | |
EDITOR = 'c:/Program Files/Sublime Text 2/sublime_text.exe' | |
files = sys.argv[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
from __future__ import print_function, unicode_literals | |
import codecs | |
import os | |
from path import path | |
import random | |
if os.name == 'nt': | |
import win_unicode_console | |
win_unicode_console.enable() |
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 json | |
import ConfigParser | |
class JSONConfig(ConfigParser.RawConfigParser): | |
def write(self, fp): | |
output = self._dict() | |
if self._defaults: | |
for (key, value) in self._defaults.items(): | |
output[key] = value | |
for section in self._sections: |
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
MouseIsOver(WinTitle) { | |
MouseGetPos,,, Win | |
return WinExist(WinTitle . " ahk_id " . Win) | |
} | |
#If WinActive("Guitar Pro 5") and MouseIsOver("Guitar Pro 5") | |
RButton:: | |
Send {LButton} | |
Send {Del} | |
Return |
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/python | |
import re | |
import csv | |
import sqlite3 | |
from contextlib import closing | |
TYPES = [ | |
('INTEGER', re.compile('^[-+]?(\d+,)*\d+$')), | |
('REAL', re.compile('^[-+]?((\d+,)*\d+)?\.?[0-9]+([eE][-+]?[0-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
#!/usr/bin/python | |
import os | |
import re | |
import urllib2 | |
AUTH_FILE = '~/vpnbook-openvpn-auth' | |
resp = urllib2.urlopen('http://www.vpnbook.com/freevpn') | |
content = resp.read() | |
match = re.search(r'(?:<\w+>)?Password(?:</\w+>)?: (?:<\w+>)?([a-zA-Z0-9]{8})(?:</\w+>)?', content) |
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
"""Fancy config. | |
This module reads data from ``default.cfg`` and ``config.cfg`` using | |
:class:`RawConfigParser` and stores sections in the module's namespace. | |
Let's take the following ``config.cfg`` for example:: | |
[section1] | |
key1 = 1 | |
key2 = 2 |
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
"""Parse positional and keyword arguments from `sys.argv`. | |
We all like :class:`argparser.ArgumentParser`. It is a great tool to build | |
command-line interfaces with many nice features and automatic coercing. | |
But sometimes it's just too verbose. At times all we need is to pass arguments | |
to a function from CLI. And I will help you. | |
Consider this ``square.py`` program:: |
OlderNewer