Skip to content

Instantly share code, notes, and snippets.

View zmarffy's full-sized avatar

Zeke Marffy zmarffy

  • USA
  • 05:27 (UTC -04:00)
  • Instagram zmarffy
View GitHub Profile
@zmarffy
zmarffy / Bing Video to Source Page.js
Created December 30, 2020 23:37
Redirect straight to source page when clicking on a Bing video link
// ==UserScript==
// @name Bing Video to Source Page
// @version 1.0
// @description redirect straight to source page when clicking on a Bing video link
// @author Zeke Marffy
// @match https://www.bing.com/videos/*
// @grant none
// ==/UserScript==
(function() {
@zmarffy
zmarffy / audiosplit.py
Last active February 17, 2021 16:00
Split an audio file by start times using `ffmpeg`
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("file", help="file to split")
parser.add_argument("name_and_time", type=lambda x: x.rsplit(
"_", 1), nargs="+", help="[name]_[time to split on]")
args = parser.parse_args()
file_extension = args.file.split(".")[-1]
@zmarffy
zmarffy / demotetocaller.py
Created November 28, 2020 07:25
A Python function that sets the user of itself if run with `sudo` to the user who used `sudo`
import os
import pwd
def demote_to_caller():
if os.geteuid() == 0:
d = pwd.getpwnam(os.environ["SUDO_USER"])
os.setgid(d.pw_gid)
os.setuid(d.pw_uid)
@zmarffy
zmarffy / getbitrate.py
Created November 14, 2020 16:56
Get the bitrate of an input file
import re
import subprocess
import sys
print(re.findall(r"(?<=rate: ).+(?=\n)",
subprocess.run(["ffmpeg", "-i", sys.argv[1]], stderr=subprocess.PIPE).stderr.decode())[0])
@zmarffy
zmarffy / jackboxjoiner.py
Created November 8, 2020 21:03
Join Jackbox games that are about to start. For confusing people around the world
import random
from itertools import chain, product
from json.decoder import JSONDecodeError
from time import sleep
import requests
from selenium import webdriver
JACKBOX_URL = "https://ecast.jackboxgames.com/room/"
USERNAME = "A GHOST"
@zmarffy
zmarffy / cda.applescript
Created November 8, 2020 20:06
Change Date Added field for a track in macOS Catalina's Music library
set d to text returned of (display dialog "Enter a date in %m%d%Y format (example: 01122020 for January 12, 2020)" default answer "" buttons {"Cancel", "Continue"} default button "Continue")
set trackFileList to {}
tell application "Music"
repeat with t in selection
set trackInfo to {}
copy POSIX path of (get location of t) to the end of trackInfo
copy (get played count of t) to the end of trackInfo
copy trackInfo to the end of trackFileList
end repeat
@zmarffy
zmarffy / gitstartfresh.sh
Created November 8, 2020 00:50
Start over on `git`
#! /usr/bin/env bash
mainBranch=$1
remote=$2
sudo rm -r .git && git init && git remote add origin $remote && git add --all && git commit -m "first commit" -a && git push -u origin $mainBranch --force
@zmarffy
zmarffy / curl_output_with_http_code_example.sh
Last active October 25, 2021 21:58
Get an HTTP response as well as the HTTP status code when using `curl`
out=$(curl "http://httpbin.org/get?key=value" -w "%{http_code}\\n" -sS)
sc=$(echo "$out" | tail -n -1)
json=$(echo "$out" | sed \$d)
echo -e "STATUS CODE:\n$sc\n\nJSON:\n$json"
@zmarffy
zmarffy / gghat.py
Last active August 30, 2023 11:41
Generate a GitHub personal access token using Selenium (because why not)
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from os.path import devnull
options = Options()
options.headless = True
driver = None
username = "somehow get a username into here"
password = "somehow get a password into here"
driver = webdriver.Firefox(service_log_path=devnull, options=options)
try:
@zmarffy
zmarffy / passworddisplayer.sh
Last active May 23, 2020 17:59
Display SSIDs and their entered passwords on Ubuntu
#!/usr/bin/env bash
shopt -s nullglob
ssids=("/etc/NetworkManager/system-connections/*")
for ssid in ${ssids[@]}; do
ssid_name=${ssid##*/}
printf "\e[1m$ssid_name\e[0m : "
password=$(cat "$ssid" | grep "psk=" | cut -c 5-)
if [ -z "$password" ]; then
echo -e "\e[91mNo password\e[39m"