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 -*- | |
from pymouse import PyMouse, PyMouseEvent | |
from threading import Thread | |
import numpy | |
class DetectMouseClick(PyMouseEvent): | |
def __init__(self): | |
PyMouseEvent.__init__(self) |
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 | |
def multisub(dict, text): | |
# Create a regular expression from the dictionary keys | |
regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys()))) | |
# For each match, look-up corresponding value in dictionary | |
return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from pykeyboard import PyKeyboard | |
k = PyKeyboard() | |
def paste(): | |
# Don't do this: | |
# k.press_key(k.control_key) |
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 multiprocessing | |
class EasyMultiProcessing(object): | |
""" | |
To Process the functions in parallel | |
""" | |
def __init__(self, |
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 threading | |
from queue import Queue | |
class EasyThreading(object): | |
""" | |
To Process the functions in parallel | |
""" |
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 sublime | |
import sublime_plugin | |
s = sublime.load_settings('var_share.sublime-settings') | |
def consume(): | |
num = s.get("test_var") | |
print("Consumer received: ", num) |
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
# To be case-insensitive, and to eliminate a potentially large else-if chain: | |
m.lower().endswith(('.png', '.jpg', '.jpeg')) |
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
>>> def process_data(a, b, c, d): | |
>>> print(a, b, c, d) | |
>>> x = {'a': 1, 'b': 2} | |
>>> y = {'c': 3, 'd': 4} | |
>>> process_data(**x, **y) | |
1 2 3 4 | |
>>> process_data(**x, c=23, d=42) |
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
>>> lst = ['a', 'a', 'a'] | |
>>> len(set(lst)) == 1 | |
True | |
>>> all(x == lst[0] for x in lst) | |
True | |
>>> lst.count(lst[0]) == len(lst) | |
True |
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
def mt(a, memo=[]): | |
a += 1 | |
print(a) | |
memo.append(a) | |
print(memo) | |
mt(1) | |
mt(2) | |
mt(3) |
OlderNewer