Skip to content

Instantly share code, notes, and snippets.

View u1i's full-sized avatar

Uli u1i

View GitHub Profile
@u1i
u1i / l.py
Created October 25, 2023 14:00
HTTP Listener
from flask import Flask, request
app = Flask(__name__)
@app.route('/', defaults={'path': ''}, methods=["GET", "POST", "PUT", "DELETE"])
@app.route('/<path:path>', methods=["GET", "POST", "PUT", "DELETE"])
def catch_all(path):
# Print the incoming request and payload
print(f"Incoming Request: {request.method} {request.url}")
if request.data:
@u1i
u1i / sl.py
Created October 23, 2023 07:34
Selenium Test
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.service import Service
# Replace with the URL of your Selenium Grid hub on localhost.
grid_hub_url = "http://localhost:4444/wd/hub"
# Set the Chrome browser options.
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless") # Example: Run Chrome in headless mode.
@u1i
u1i / doit.sh
Created October 23, 2023 07:33
Selenium Docker
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome
import time
from locust import HttpUser, task, between
class QuickstartUser(HttpUser):
wait_time = between(1, 2)
@task
def index_page(self):
self.client.get("/")
@u1i
u1i / 2048.py
Created July 2, 2023 08:09
2048 Game in Python
import curses
from random import randrange, choice
from collections import defaultdict
# Initialize the game
actions = ['Up', 'Down', 'Left', 'Right']
keys = [ord('w'), ord('s'), ord('a'), ord('d')]
actions_dict = dict(zip(keys, actions))
@u1i
u1i / doit.sh
Created May 17, 2023 11:18
Chrome Watcher - what files does it read and write
#!/bin/bash
# Array to store the filenames from the previous loop
previous_files=()
# Infinite loop
while :
do
# Run the lsof command and filter for Google Chrome process
files=$(lsof -c "Google Chrome" | awk '{print $9}' | sed '1d')
@u1i
u1i / doit.sh
Created May 16, 2023 11:16
Open URL in existing Chrome instance
osascript -e 'tell application "Google Chrome" to open location "https://www.sotong.io"'
@u1i
u1i / doit.sh
Created May 16, 2023 03:56
MacOS: gracefully close Firefox
osascript -e 'tell application "Firefox" to quit'
@u1i
u1i / info.txt
Created May 16, 2023 03:29
Firefox: History
SELECT moz_places.url, datetime(moz_historyvisits.visit_date / 1000000,'unixepoch', 'localtime') AS visit_time FROM moz_places JOIN moz_historyvisits ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC LIMIT 10;
@u1i
u1i / info.txt
Created May 16, 2023 03:13
Chrome History
SELECT url FROM urls ORDER BY last_visit_time DESC LIMIT 10;