Skip to content

Instantly share code, notes, and snippets.

View pykong's full-sized avatar
🎯
Focusing

Ben Felder pykong

🎯
Focusing
View GitHub Profile
@pykong
pykong / EasyMultiProcessing.py
Created May 12, 2017 11:35
Very easy interface for multi-processed execution of functions in python.
import multiprocessing
class EasyMultiProcessing(object):
"""
To Process the functions in parallel
"""
def __init__(self,
@pykong
pykong / EasyThreading.py
Last active June 18, 2017 13:58
Very simple interface for multi-threaded execution of functions in python.
import threading
from queue import Queue
class EasyThreading(object):
"""
To Process the functions in parallel
"""
@pykong
pykong / Paste.py
Created October 15, 2016 13:40
Example of how to paste text with pykeyboard.
#!/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)
@pykong
pykong / MultipleSubstitution.py
Last active October 10, 2016 21:37
Substitute multiple patterns in string with those in a provided dictionary.
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)
@pykong
pykong / MouseDelta.py
Created October 7, 2016 17:39
Gets mouse delta as (x, y) tuple of coordinates.
#!/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)