Skip to content

Instantly share code, notes, and snippets.

@alydevs
alydevs / hlstranscode.sh
Last active July 30, 2021 05:23
A script to launch a DO droplet with a script to download a file via http, transcode it using video2hls, upload the results to b2:ads-share/hls, then delete itself
#!/bin/bash
# hlstranscode $URL
cat >/tmp/cloud.conf <<EOFF
#!/bin/bash
apt-get update -qq
apt-get install ffmpeg -y -qq
curl https://rclone.org/install.sh | bash 2>/dev/null >/dev/null
export ID=\$(curl http://169.254.169.254/metadata/v1/id 2>/dev/null)
#!/usr/bin/env python3
# let's say you have a bucket on b2 containing videos which you've converted,
# using https://github.com/vincentbernat/video2hls, to a HLS file structure
# in subdirectories named for the sha1 sum of the original file.
# This script would produce an index of files available via HLS by parsing
# the output of `b2 ls BUCKET DIRECTORY --json --recursive` (available as
# data.json), returning json like
# [
# ["d5db29cd03a2ed055086cef9c31c252b4587d6d0",
# "filename.mp4"],
@alydevs
alydevs / cors.js
Last active July 21, 2021 23:27
cors proxy cloudflare worker
// We support the GET, POST, HEAD, and OPTIONS methods from any origin,
// and allow any header on requests. These headers must be present
// on all responses to all CORS preflight requests. In practice, this means
// all responses to OPTIONS requests.
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
"Access-Control-Max-Age": "86400",
}
@alydevs
alydevs / archive_size
Created July 8, 2021 22:55
A tool to get the size of an archive.org bucket
#!/usr/bin/env python3
import xmltodict
import requests
def sizeof_fmt(num, suffix='B'):
for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
if abs(num) < 1024.0:
return "%3.1f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.1f%s%s" % (num, 'Yi', suffix)
@alydevs
alydevs / acnhmusic.py
Created July 8, 2021 01:07
plays the acnh soundtrack synced to real time kinda
#!/usr/bin/env python3
# videos from https://tane.us/ac/nhIds.js, rename to hh00.m4a
# python3 acnhmusic.py | mpv - --loop-playlist=inf
from glob import glob
from datetime import datetime
from sys import stderr
print("#EXTM3U")
files = sorted(glob("*.m4a"))
@alydevs
alydevs / dur
Last active July 1, 2021 23:16
A script to get total duration of files provided in arguments. Python3 and ffprobe
#!/usr/bin/env python3
from sys import stderr, argv, exit
import subprocess
from math import floor
def hms(inp):
s,ms = divmod(inp,1)
m,s = divmod(s,60)
h,m = divmod(m,60)
return f"{h:02.0f}:{m:02.0f}:{s:02.0f}.{floor(ms*100):02.0f}"
@alydevs
alydevs / ending1.md
Last active June 6, 2021 20:52
A guide for all endings in Analogue: A Hate Story, and some notes

Ending 1: *Hyun-ae leaves home, in the care of a new friend

tbd

@alydevs
alydevs / vultrwin.sh
Last active April 25, 2021 20:54
A windows startup cmd script, and bash script to execute it on vultr. installs all the things i think are useful to have on a new windows server
#!/bin/bash
domain="alyssasmith.id.au"
if [ -z "$1" ]; then
region="syd"
else
region="$1"
fi
if [ -z "$2" ]; then
size="vc2-4c-8gb"
else
@alydevs
alydevs / tdsdec.sh
Created April 12, 2021 07:22
Linux .3ds decrypt
#!/bin/bash -x
# https://gbatemp.net/download/batch-cia-3ds-decryptor.35098/
# adapted from the .bat file in this zip
# requires wine
# intended for e.g Homebrew.Game.Title/asdf.rar, produces Homebrew.Game.Title.3ds as decrypted output
_PWD=$(pwd)
DECRYPTPATH=/root
cd "$1"
unrar -o+ x $(find . -name *.rar | head -n1)
echo | wine $DECRYPTPATH/decrypt.exe *.3ds
@alydevs
alydevs / win-remote-ssh.ps1
Last active March 13, 2021 14:17
A script that should configure a given windows machine to have openssh running at least. opens vim to paste in authorized keys, installs scoop as well
Set-ExecutionPolicy RemoteSigned
New-Item -path $profile -type file -force
Add-Content -path $profile -value '[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"'
& $profile
iwr -useb get.scoop.sh | iex
scoop install git
scoop update
iwr https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Beta/OpenSSH-Win64.zip -outfile "C:\Program Files\OpenSSH-Win64.zip"
expand-archive -path "C:\Program Files\OpenSSH-Win64.zip" -destinationpath "C:\Program Files"
move-item "C:\Program Files\OpenSSH-Win64" "C:\Program Files\OpenSSH"