Skip to content

Instantly share code, notes, and snippets.

@justengel
justengel / find_prices.py
Created October 5, 2023 00:14
Check prices and report on the cheapest price found
"""
Check and store the prices of an item.
Create a find_prices.json file and run daily to see if prices changed.
..code-block:: json
{
"Coffee Maker": {
"Vendor": {
@justengel
justengel / screen_print.py
Last active October 5, 2023 02:51
Replace print with a new terminal buffer screen
import sys
import builtins
import time
import warnings
from functools import wraps
def skip_without_screen(func):
@wraps(func)
def decorated(*args, **kwargs):
@justengel
justengel / ssh_tools.py
Last active March 24, 2023 13:49
Quickly change a ssh config HostName as well as reading and configuring the .ssh/config file.
#!/usr/bin/env python
"""
Quickly change a ssh config HostName as well as reading and configuring the .ssh/config file.
Also supports syncing a pycharm http client env file.
"""
import fire
import shlex
@justengel
justengel / async_serial_logger.py
Last active August 19, 2020 17:03
Asyncio serial port logger. This works, but has not been tested for efficiency.
"""Asyncio serial port logger.
Requirements:
* pyserial
* pyserial-asyncio
* aiofiles
"""
import os
@justengel
justengel / keep_awake.py
Last active August 18, 2020 17:39
Keep windows 10 awake while this script is running.
"""Keep windows awake.
Build an executable with "pyinstaller ./keep_awake.py --noconsole --onefile"
Prevent OS sleep/hibernate in windows
* Derived from: https://stackoverflow.com/a/57647169/1965288
* code from: https://github.com/h3llrais3r/Deluge-PreventSuspendPlus/blob/master/preventsuspendplus/core.py
* API documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/aa373208(v=vs.85).aspx
@justengel
justengel / upload_package.py
Created June 29, 2020 16:07
Change a library version and upload it to pypi.
"""
Change a library version and upload it to pypi.
If you are updating the version, this script assumes a __meta__.py file exists in the package you want to upload.
Warning:
This has not been tested on all platforms!
Requirements:
* shell_proc>=1.1.1
@justengel
justengel / mortgage_calculator.html
Last active June 23, 2020 21:10
Calculate mortgage payments.
<html>
<head>
<title>Mortgage Calculator</title>
</head>
<body>
<h1>Mortgage Calculator</h1>
<h2>References</h2>
<ul>
@justengel
justengel / gcal_scheduler.py
Last active September 19, 2022 04:40
Quick google calendar utilities
"""
https://developers.google.com/calendar/v3/reference/events/insert
"""
import os
import pickle
import datetime
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
@justengel
justengel / office_to_html.py
Last active April 23, 2023 19:15
Convert Microsoft Office documents to html or pdf files that can be viewed in a web browser.
"""Convert office document to file formats that may be visible in a web browser. This file uses microsoft office to
convert the files, so Windows OS is assumed and required!
Requirements:
* pywin32>=228 # Not available for Python3.8 at this time
Server Requirements:
* uvicorn>=0.11.5
* fastapi>=0.58.0
* python-multipart>=0.0.5
@justengel
justengel / merge_pdf.py
Created June 4, 2020 19:36
Merge multiple pdf files into one pdf file.
"""
Merge multiple pdf files into one pdf file.
Args:
f (list/str): List of filenames to merge
out (str): Save filename to merge all of the files into.
Requires:
* pip install PyPDF2