Skip to content

Instantly share code, notes, and snippets.

View ileathan's full-sized avatar

Spinelli Valentinuzzi ileathan

View GitHub Profile
add=(_=>n=>_+=n)(0)
add(5) // => 5
add(10) // => 15
add(7) // -> 22
true|0**0 === 1; // true
NaN|0**0 === 1; // true
false|0**0 === 1; // true
// ...
@ileathan
ileathan / base-x encoder gist
Last active January 29, 2018 00:39
Continually mod and map.
encode = (n, a) => {
var r = [];
do {
n = (n - (r[r.length] = n % a.length)) / a.length
} while(n);
return r.map(n=>a[n]).reverse().join('')
};
encode(4095, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/')
// Outputs "//"
@ileathan
ileathan / remote-sudo.sh
Last active January 29, 2018 00:33
Run sudo command on remote machine non-interactively
#!/bin/bash
# USAGE:
# ./remote-sudo.sh password hostname command
HOST=$2;
PASSWORD=$1;
COMMAND="${@:3}"
ssh -T $HOST "echo $PASSWORD | sudo -S su -c \"$COMMAND\""
@ileathan
ileathan / android-man-install.sh
Last active January 29, 2018 00:34
Install man pages without or with conflicting binaries
#!/bin/bash
# This script assumes you have an ssh server running on your rooted android.
# USAGE:
# ./android-man-install.sh binaryName
# Locate the man page you want. From a computer that already has it:
location=$(sudo find / * | grep -P "$1\\..*\\.gz")
# Now scp over the file you just found (from remote pc to android).
scp $location yourAndroidDevice:$location
@ileathan
ileathan / install_powershell.sh
Created November 28, 2020 12:08
Install powershell on linux (kali-rolling)
# Dependencies
sudo apt-get install libicu63
sudo apt-get install liblttng-ust0
# Download closest thing to kali
# Its updated constantly so just get the latest debian file.
# https://github.com/PowerShell/PowerShell/releases/tag/v7.1.0
wget https://github.com/PowerShell/PowerShell/releases/download/v7.1.0/powershell_7.1.0-1.debian.11_amd64.deb
# Install
@ileathan
ileathan / thumbnailrestore.sh
Last active October 27, 2023 03:29
Aurora coverart restore / sharing
set -o errexit -o nounset
# The idea is simple, the format Aurora uses is #GameID_DatabaseID where the GameID stays the same and the DatabaseID changes, so we check only the first 8 chars of the backup and the new and if they match we copy over the backups cover file to the new gamedata.
for file in GameData.bak/*; do
# Remove the following as they arnt games?
for file2 in GameData/*; do
if [ "${file2:9:8}" == "00000000" ]; then
continue
fi
if [ "${file2:9:2}" == "FF" ]; then
# USAGE: RetroArchRenameBoilerPoint.sh ./Nintendo\ -\ Nintendo\ Entertainment\ System.lp
IFS=$'\n'
for filename in $(cat "$1" | grep -oP '.*"path": ".*/\K.*\.[^"]*'); do
romname=$(echo $filename | perl -pe 's/([[\]()+\$^{}])/\\$1/g')
romname=$(cat "$1" | grep -zoP "(/|\\\)$romname"'",\s{7}\"label\": \"\K[^"]*')
romname=$(echo "$romname" | perl -pe 's/[&*\/:`<>?\|]/_/g')
if [[ "${filename:0:-4}" == "$romname" ]]; then
:
else
#
# Renames all retroarch thumbnails names, roms names, and reupdates the playlist.lpl files with said information.
#
# If your playlists names match your rom directories this will rename all cusom images and roms according to the lpl
# file passed in. Copy all your playlists over to where this script is located and from a wsl (windows subsystem for linus) console
# and ussage would be:
#
# bash rename.sh "PlaylistFile.lpl" "/your/retroarch/thumbnails/folder" "/your/retroarch/roms/folder" "/your/retroarch/playlists/folder"
#
# To update your entire retroarch at once you can follow the above advice and run:
@ileathan
ileathan / rename2.sh
Last active October 27, 2023 03:28
Same as my last gist but probably what more people want. Renames custom pictures correctly.
# Just move the images.
# Usage: bash rename2.sh "playlistfile.lpl" "/retroarch/thumbnails/folder"
IFS=$'\n'
for file in $(cat "$1" | grep -oP '.*"path":.*/\K.*\.([^"]*)'); do
ext=${file##*.}
escfile=$(echo $file | perl -pe 's/([[\]()+\$^{}])/\\$1/g')
newname=$(cat "$1" | grep -zoP "(/|\\\)$escfile"'",\s*\"label\": \"\K[^"]*')
newname=$(echo "$newname" | perl -pe 's/[&*\/:`<>?\|]/_/g')
dir="${1:0:-4}"
if [[ "${file:0:-((${#ext}+1))}" != "$newname" ]]; then