Skip to content

Instantly share code, notes, and snippets.

View svrj's full-sized avatar

Jeremy Savor svrj

View GitHub Profile
@svrj
svrj / main.py
Created February 14, 2020 11:16
Simple terminal with external program interaction
import sys
from PyQt5 import (QtCore as QTC,
QtGui as QTG,
QtWidgets as QTW)
class Terminal(QTW.QWidget):
def __init__(self, parent=None):
super(Terminal, self).__init__(parent)
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@svrj
svrj / one_line_webserver.sh
Created September 21, 2020 09:28
One-line Webserver
## Usage:
## bash one_line_webserver.sh
##
## Then, in a browser, navigate to http://localhost:18080
## or
## curl localhost:18080
##
## Thanks, Roberto Giona
while true; do (echo -n -e "HTTP/1.1 200 OK\r\n\r\n"; echo ciao) | nc -l 18080 -w 0; done
@svrj
svrj / rescale_image.sh
Last active July 20, 2022 18:07
Rescale an image
#!/bin/bash
### ###################################
### # Rescale the given image while
### # preserving the aspect ratio
### #
### # Example Usage:
### # Basic rescaling:
### # > rescale_image < width x height > path/to/image path/to/new_image
### #
@svrj
svrj / transparent_background.sh
Last active July 20, 2022 18:07
Make image background transparent
#!/bin/bash
### ####################################
### # Convert the given image background
### # to be transparent and save to new
### # location
### #
### # Example Usage:
### # Basic conversion:
### # > transparent_background path/to/image path/to/new_image
### #
@svrj
svrj / main.py
Created April 21, 2021 15:48
TPLink HS100 Control with Python (>=3.7)
"""
A little bit of background to controlling the hs100 without a phone: https://blog.georgovassilis.com/2016/05/07/controlling-the-tp-link-hs100-wi-fi-smart-plug/
"""
import asyncio
import kasa # https://github.com/python-kasa/python-kasa
import time
import sys
IP = "10.10.185.105"
@svrj
svrj / stream.py
Created June 3, 2021 14:10
Multiple Webcam Streaming
"""
Stream from connected USB Webcams (on Ubuntu 18.04)
During preliminary testing, there were issues when trying to stream from a USB
hub. It's important that each camera has a dedicated USB port rather than a connection
via a hub. Perhaps, it's actually a problem with the hub, and a better one could support
the data rate for multiple cameras?
"""
import cv2
import pathlib
@svrj
svrj / parse_fco_failures.py
Created October 12, 2021 07:41
Parsing/Counting FCO failures in SPT
from SigmaProductionTools.utils.configuration import conf
from SigmaProductionTools.utils.database import Database
import pathlib
def parse_result(result: dict, predicate) -> bool:
text = result["text"]
step_text = text.split("||")
found = False
@svrj
svrj / gs_connection.mmd
Created April 6, 2022 15:06
GS Connection Flow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@svrj
svrj / logging_decorator.py
Last active May 13, 2022 13:34
Use a decorator to add print/logging statements before invoking classes or functions
import inspect
def logging_decorator(thing):
if isinstance(thing, type):
def inner(*args, **kwargs):
for t in dir(thing):
if not t.startswith("__"):
_thing = getat