Skip to content

Instantly share code, notes, and snippets.

View 4piu's full-sized avatar
ROLLING BACK

4piu 4piu

ROLLING BACK
View GitHub Profile
@4piu
4piu / dominion-energy-usage-sync.py
Created February 25, 2025 13:18
Get Dominion Energy hourly usage data, then save to SQLite. Login with Selenium+Chrome
import datetime
import logging
import logging.config
import os
import pickle
import pytz
import requests
import sqlite3
from selenium import webdriver
from selenium.webdriver.common.by import By
@4piu
4piu / gmail-cleaner.py
Last active March 5, 2025 19:52
Automatically move promotion and updates email older than 30 days to trash. Require OAuth app created on GCP.
import logging
import logging.config
import os.path
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
@4piu
4piu / setup-python-embed.ps1
Created November 30, 2024 03:33
Setup Python embeddable package as portable python. Installs `pip` and `virtualenv`
param (
[Parameter(Mandatory = $true)]
[string]$PythonFolderPath
)
# Ensure the provided path exists
if (-Not (Test-Path -Path $PythonFolderPath)) {
Write-Error "The specified path '$PythonFolderPath' does not exist."
exit 1
}
@4piu
4piu / sun8i-h3-ili9341-touchscreen.dts
Created September 1, 2024 21:56
Overlay file for ili9341 touchscreen module
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,sun8i-h3";
fragment@0 {
target = <&pio>;
__overlay__ {
spi0_cs1: spi0_cs1 {
@4piu
4piu / del-credential.ps1
Created May 30, 2024 20:37
Delete Windows credential with specified regex pattern
# Prompt the user for the pattern
$pattern = Read-Host "Delete Credential with Regex pattern"
# Filter credentials that start with the specified prefix
$regex = "^ Target: (?:LegacyGeneric:target=)*" + $pattern + "$"
$creds = cmdkey /list | Select-String -Pattern $regex
# Remove each credential that starts with the specified prefix
foreach ($cred in $creds) {
$target = $cred -replace "^\s*Target: ", ""
@4piu
4piu / script.user.js
Created May 19, 2024 18:17
Allow Oculus screen casting to be displayed in theater mode
// ==UserScript==
// @name Theater Mode
// @namespace http://tampermonkey.net/
// @version 2024-05-19
// @description Allow the video to occupy the whole webpage
// @author Nobody
// @match http*://*.oculus.com/casting
// @icon https://www.google.com/s2/favicons?sz=64&domain=oculus.com
// @grant none
// ==/UserScript==
@4piu
4piu / bmp2csv.py
Created March 6, 2024 17:31
Convert grayscale bitmap image to a csv where each cell is 0-255
#!/usr/bin/env python3
from PIL import Image
import csv
def convert_image_to_csv(image_path, csv_path):
# Open the image
with Image.open(image_path) as img:
# Convert image to grayscale (if it's not already)
img = img.convert('L')
@4piu
4piu / fill-screen-aspect-ratio-range.html
Created December 11, 2023 14:10
Fill screen with a div with a limited-range aspect ratio, and rotate 90 degree on portrait screen
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>My FullScreen App</title>
</head>
<body>
<div id="app">
<h1>My FullScreen App</h1>
@4piu
4piu / fill-screen-fixed-aspect-ratio.html
Last active December 11, 2023 13:12
Fill screen with a fixed-aspect-ratio div, and rotate 90 degree on portrait screen
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>My FullScreen App</title>
</head>
<body>
<div id="app">
<h1>My FullScreen App</h1>
@4piu
4piu / pwa-everything.user.js
Last active April 13, 2024 14:03 — forked from evanreichard/pwa-everything.user.js
pwa-everything.user.js
// ==UserScript==
// @name PWA Everything
// @author Evan Reichard
// @version 0.0.1
// @match *://*/*
// @grant none
// @run-at document-idle
// @noframes
// ==/UserScript==