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
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# C extensions | |
*.so | |
# Distribution / packaging | |
.Python |
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 argparse | |
class ActionFlagWithNo(argparse.Action): | |
""" | |
Allows a 'no' prefix to disable store_true actions. | |
For example, --debug will have an additional --no-debug to explicitly disable it. | |
""" | |
def __init__(self, opt_name, dest=None, default=True, required=False, help=None): | |
super(ActionFlagWithNo, self).__init__( | |
[ |
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 python2 | |
import signal | |
from gi.repository import Gtk | |
def bind_accelerator(accelerators, widget, accelerator, signal='clicked'): | |
key, mod = Gtk.accelerator_parse(accelerator) | |
widget.add_accelerator(signal, accelerators, key, mod, Gtk.AccelFlags.VISIBLE) |
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
Oniguruma Regular Expressions Version 5.9.1 2007/09/05 | |
syntax: ONIG_SYNTAX_RUBY (default) | |
1. Syntax elements | |
\ escape (enable or disable meta character meaning) | |
| alternation | |
(...) group |
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 numbers | |
class Percent(float): | |
def __mod__(self, other): | |
"""Override the builtin % to give X * Y / 100.0 """ | |
return self / other * 100.0 | |
if __name__ == '__main__': | |
from pprint import pprint | |
pprint( |
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 | |
"""Make the X cursor wrap-around. | |
Adapted from http://appdb.winehq.org/objectManager.php?sClass=version&iId=12599 | |
to work around lack of relative mouse movement http://wiki.winehq.org/Bug6971 | |
for Thief: Dark Shadows (and possibly others) | |
This version is a little kinder to your CPU than the shell script with | |
the busy-loop that starts a new process for every pointer query. | |
""" |
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
python -c "import sys, subprocess; p = subprocess.Popen(['xclip', '-selection', 'clipboard'], stdin=subprocess.PIPE); p.communicate(input=bytes((' '.join(sys.argv[1:]) + '\n').split('http://')[-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
#!/usr/bin/env python2 | |
# | |
# LICENSE | |
# This is free and unencumbered software released into the public domain. | |
# | |
# Anyone is free to copy, modify, publish, use, compile, sell, or | |
# distribute this software, either in source code form or as a compiled | |
# binary, for any purpose, commercial or non-commercial, and by any | |
# means. | |
# |
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 python3 | |
""" Example multiprocess based python file | |
""" | |
import multiprocessing | |
import argparse | |
import itertools | |
ARGP = argparse.ArgumentParser( |
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 python2 | |
""" | |
Double Helix Text | |
""" | |
import argparse | |
import math | |
import sys | |
import time |