Skip to content

Instantly share code, notes, and snippets.

# brew install portaudio blackhole-2ch
# uv add pyautogui opencv-python sounddevice numpy pynput
import sounddevice as sd
import numpy as np
import pyautogui
import cv2
import time
import threading
import random
import abc
import requests
from urllib3.util.retry import Retry
class BaseClient(abc.ABC):
def __init__(self):
self.session = requests.Session()
retry = Retry(
# if we get stuck in some kind of loop,
@adamyala
adamyala / pre-commit-lint.py
Created January 22, 2019 21:41
pre-commit python line
import os
import sys
import subprocess
if not os.getenv('PYTHON_PRECOMMIT'):
sys.exit()
def run_command(command):
command_list = command.split()
@adamyala
adamyala / download.py
Created January 14, 2019 19:48
python script to download records from http://edms.deq.louisiana.gov
# import core python libs
# urls lib will help us take the download urls apart
from urllib.parse import urlparse, parse_qs
# the download needs time to build so we'll sleep
from time import sleep
# import 3rd party libs
# requests is the standard for making http requests in python
import requests
@adamyala
adamyala / sendgrid.py
Created December 5, 2018 02:05
A SendGrid client for Viant
import sendgrid
class EmailClient:
def __init__(self):
self.sendgrid = sendgrid.SendGridAPIClient(apikey=SENDGRID_API_KEY)
self.template_map = {
'act-on-asset': '2056279c-ba35-431f-bd8f-e72df9a46c32',
'welcome-email': '899efc03-4780-4537-a7e6-a4555c531c08',
}
@adamyala
adamyala / human-logging.py
Created April 10, 2017 19:02
An ansible callback that pretty prints your error messages
# To get this working:
# add the below line to your ansible.cfg defaults
#
# [defaults]
# callback_plugins = path/to/ansible-callbacks/human-logging.py
# put the below code into the human-logging.py file
#
# tested thoroughly with ansible 2.2.1.0
class CallbackModule(object):
@adamyala
adamyala / Python Console Autocomplete
Created September 22, 2016 21:47
Python Console Autocomplete
import rlcompleter, readline
readline.parse_and_bind('tab:complete')