Skip to content

Instantly share code, notes, and snippets.

View kyletimmermans's full-sized avatar
:electron:

Kyle Timmermans kyletimmermans

:electron:
View GitHub Profile
@kyletimmermans
kyletimmermans / MacOS-to-Linux-File-Cleanup.sh
Created July 3, 2024 14:16
Useful script to remove extra MacOS metadata files when moving files from MacOS to Linux. Also remove any Solidus characters (slash) from filenames which are allowed on Mac but not in Linux
# Remove .DS_Store Files
find . -name ".DS_Store" -type f -delete
# Remove AppleDouble Files
find . -name '._*' -exec rm {} \;
# Change Any Illegal Solidus Chars in Filename to Fraction Slash
TARGET_CHAR=$(echo -ne '\xef\x80\xa2')
REPLACEMENT_CHAR="⁄"
find . -depth -name "*$TARGET_CHAR*" -print0 | while IFS= read -r -d '' file; do
@kyletimmermans
kyletimmermans / PDFjs-Template.html
Created June 26, 2024 15:15
A template for embedding a PDF into a webpage using PDF.js - Equipped with all the settings needed to maximize PDF display quality
<!DOCTYPE html>
<html dir="ltr" translate="no">
<head>
<title>PDF.js viewer template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<!-- Necessary imports for PDF.js-->
@kyletimmermans
kyletimmermans / No-Preview-Download-Button.html
Created June 26, 2024 15:13
An HTML button element that can be clicked to download a PDF directly instead of previewing it in the browser
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script>
@kyletimmermans
kyletimmermans / CircleEdgePoint.py
Last active April 10, 2024 13:58
The Python code and math for finding the coordinates of a point on the edge of a circle where a line between two points intersects on the circle, the two points being: the center of the circle (A) and the point outside of the circle (B). This math can be used to draw a line cleanly from the edge of a circle without it overlapping the circle itself.
from math import sqrt
# https://math.stackexchange.com/questions/127613/closest-point-on-circle-edge-from-point-outside-inside-the-circle
def circle_edge_point(x1, y1, x2, y2, r):
try:
cx = x1 + (r * (x2 - x1) / sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2))
except ZeroDivisionError:
# Add 0.0001 if divisor is 0
cx = x1 + (r * (x2 - x1) / sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) + 0.0001)
@kyletimmermans
kyletimmermans / aliases-functions.sh
Last active February 26, 2024 02:42
Collection of useful / helpful Bash aliases and functions I've found / edited / created
alias ..='cd ..' # Faster
alias cls='clear' # Faster
alias ll='ls -lhFA' # Better ls
alias vi='vim' # Use vim instead
alias neofetch='fastfetch' # Better neofetch
alias psa='ps aux | grep --color=auto' # View process(es) by name e.g. psa 'sudo find'
alias hs='history | grep --color=auto' # Search through command history e.g. 'git diff'
alias open='xdg-open' # Linux version of OSX open (Open directory in file explorer)
alias pbcopy='xclip -selection clipboard' # Linux version of OSX pbcopy (Copy text to clipboard)
alias pbpaste='xclip -selection clipboard -o' # Linux version of OSX pbpaste (Paste text from clipboard)
@kyletimmermans
kyletimmermans / .zshrc
Created February 23, 2024 02:10
A collection of Zsh terminal prompts
# Kali Linux
PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}(%B%F{%(#.red.blue)}%n%(#.💀.㉿)%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '
RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'
# Parrot OS
PROMPT="%F{red}┌[%f%F{cyan}%m%f%F{red}]─[%f%F{yellow}%D{%H:%M-%d/%m}%f%F{red}]─[%f%F{magenta}%d%f%F{red}]%f"$'\n'"%F{red}└╼%f%F{green}$USER%f%F{yellow}$%f"
@kyletimmermans
kyletimmermans / netinfo-sysinfo.sh
Last active February 22, 2024 13:21
Network and system info for *nix OS terminal (.bashrc / .zshrc)
# List network information
netinfo() {
if [[ $(uname -s) != *"Darwin"* ]]; then
sudo echo -n ""
fi
echo -e "\n---------------- Network Information ----------------"
echo "Hostname: $(hostname)"
if [[ $(uname -s) == *"Darwin"* ]]; then
echo "Local IP: $(ipconfig getifaddr $(route -n get default | grep interface | awk '{print $2}'))"
echo "Network Interface: $(route -n get default | grep interface | awk '{print $2}')"
@kyletimmermans
kyletimmermans / MeetingExiter.js
Last active January 11, 2024 02:05
A script to automatically leave meetings / exit a webpage after a given amount of time
/* Run in your browser's JS console */
MeetingExiter = () => {
// Don't allow it to be running more than once
if (typeof meetingExiterMutex !== "undefined") {
if (meetingExiterMutex === true) {
console.error("Cant't run more than 1 exiter job at a time!");
return;
} else {
meetingExiterMutex = true;
}
@kyletimmermans
kyletimmermans / pop_os_super_updater.sh
Last active February 22, 2024 23:58
Pop!_OS Super Updater
#!/usr/bin/env bash
# Credits to Willi Mutschler @ mutschler.dev for the update commands
# https://mutschler.dev/linux/pop-os-post-install/
echo -e "\nThis program requires that your machine is connected to"
echo "a power source and that you are connected to the internet."
echo -e "\nTHIS PROGRAM WILL REBOOT YOUR MACHINE AFTER IT FINISHES!\n"
read -p "Are you connected to a power source and the internet? (Y/n): " reply
@kyletimmermans
kyletimmermans / github_backup.sh
Last active June 30, 2024 13:59
GitHub Repo & Gist Backup Script
#!/usr/bin/env bash
# Change the shebang above^ if need be (zsh, etc...)
# Must have jq & gh (GitHub CLI tool) installed
# Get personal access token with access to "repos" and "gists" in developer settings
read -p "Enter Username: " username
read -p "Enter Access Token: " token
read -p "Download Repositories? (Y/n): " getrepos
read -p "Download Gists? (Y/n): " getgists