Skip to content

Instantly share code, notes, and snippets.

View tallpeak's full-sized avatar

Aaron William West tallpeak

View GitHub Profile
@tallpeak
tallpeak / Exponential_Regression.py
Last active April 8, 2024 12:51
estimate cost of an in-game item ("Strength Upgrades" in Lumberjack Heroes in Fortnite)
# A program to estimate the formula for cost of an in-game item;
# Specifically, "Strength Upgrades" in Lumberjack Heroes in Fortnite
# https://chat.openai.com/c/e8e7f768-e9d7-4553-94aa-4e9b5b12d917
# count,cost
# 1,55.8E45
# 10,1.13E48
# 100,11.5E51
counts = [1, 10, 100]
@tallpeak
tallpeak / pidigits.hs
Created March 16, 2024 02:41
digits of pi
import System.Environment
pidigits digits = sum (map piterm [1..(digits - digits `div` 5)]) where
kk = 10 ^ digits
piterm k = kk * 16*(-1)^(k+1)`div`((2*k-1)*5^(2*k-1)) - kk * 4*(-1)^(k+1)`div`((2*k-1)*239^(2*k-1))
main = do
args <- getArgs
let digits :: Integer = read (head args)
print $ pidigits digits
@tallpeak
tallpeak / show_dynamic_html.js.txt
Last active January 29, 2024 21:16
paste into Javascript console when you want dynamically-generated HTML source of the page (if view source shows very little)
addEventListener("focus", (event) =>
navigator.clipboard.writeText(document.body.innerHTML)
.then(()=>console.log("string copied to clipboard")) );
@tallpeak
tallpeak / unmanaged.bat
Last active January 14, 2024 18:00
If MSEdge says "Microsoft Edge is managed by your organization", run this to remove the message
@echo Be sure to run this as administrator!
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge" /f
reg delete "HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Edge" /f
@echo Verify success
PAUSE
@tallpeak
tallpeak / empty_tables.sql
Last active December 11, 2023 04:17
All empty tables in a Postgresql database
drop FUNCTION empty_tables;
CREATE OR REPLACE FUNCTION empty_tables()
RETURNS TABLE(name text) AS
$BODY$
DECLARE
t record;
v_sql text;
hasdata bool;
BEGIN
@tallpeak
tallpeak / sdcdimport.py
Last active November 16, 2023 21:13
SDCD download with Selenium webdriver (Chrome)
#https://gist.github.com/tallpeak/c8a9254370b24b8fbab6a5c803204370
#based on https://www.guru99.com/selenium-python.html
from selenium import webdriver
from selenium.webdriver.common.by import *
from selenium.webdriver.support.ui import WebDriverWait
import sys
import os
arg1 = len(sys.argv) > 1 and sys.argv[1] or ""
if arg1 == "-f" or arg1 == "--full" or arg1=="f" or arg1=="full":
full = True
@tallpeak
tallpeak / map_pattern_match.py
Last active November 2, 2023 00:25
structural pattern matching of a map
# Simplified example of how to handle throttling of requests returned from the Shopify API
import json
import time
# The web API (GraphQL API) returns a JSON string similar to this:
content = b'{"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}'
obj = json.loads(content) # Convert it to a Python object (a map)
# Actual code to retrieve part of the object from the full JSON from the Shopify GraphQL API:
# throttleStatus = js["extensions"]["cost"]["throttleStatus"]
# Simplified:
throttleStatus = obj["throttleStatus"]
#! /usr/bin/env python3
import re
import os
pid = int(os.popen("grep -a ^./asmttpd /proc/[0-9]*/cmdline | cut -d/ -f3") .read())
maps_file = open(f'/proc/{pid}/maps', 'r')
mem_file = open(f'/proc/{pid}/mem', 'rb', 0)
output_file = open("self.dump", 'wb')
for line in maps_file.readlines(): # for each mapped region
m = re.match(r'([0-9A-Fa-f]+)-([0-9A-Fa-f]+) ([-r])', line)
if m.group(3) == 'r': # if this is a readable region
@tallpeak
tallpeak / morse.rs
Last active September 1, 2023 07:32
morse code decoder in Rust, converted from morse.py by ChatGPT 3.5, no errors!
use std::collections::HashMap;
fn main() {
let morse: Vec<&str> = vec![
" ", "-.-.--", ".-..-.", "", "...-..-", "", ".-...", ".----.", "-.--.", "-.--.-", "",
".-.-.", "--..--", "-....-", ".-.-.-", "-..-.", "-----", ".----", "..---", "...--",
"....-", ".....", "-....", "--...", "---..", "----.", "---...", "-.-.-.", "", "-...-",
"", "..--..", ".--.-.", ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",
".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-",
"...-", ".--", "-..-", "-.--", "--..", "", "", "", "", "..--.-"
@tallpeak
tallpeak / morse.py
Created September 1, 2023 05:52
morse code decoder, converted from perl by ChatGPT
morse = [' ', '-.-.--', '.-..-.', '', '...-..-', '', '.-...', '.----.', '-.--.', '-.--.-', '',
'.-.-.', '--..--', '-....-', '.-.-.-', '-..-.', '-----', '.----', '..---', '...--',
'....-', '.....', '-....', '--...', '---..', '----.', '---...', '-.-.-.', '', '-...-',
'', '..--..', '.--.-.', '.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..',
'.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-',
'...-', '.--', '-..-', '-.--', '--..', '', '', '', '', '..--.-']
ascii_value = 32
morseAscii = {}