Skip to content

Instantly share code, notes, and snippets.

View bootrino's full-sized avatar

bootrino bootrino

  • Melbourne, Australia
View GitHub Profile
@bootrino
bootrino / gist:53c4865f91f2208d2ddd4a1fadd69f58
Last active February 12, 2024 10:51
Compile ffmpeg with nvenc for Ubuntu 22
#!/bin/bash
#This script will compile and install a static ffmpeg build with support for nvenc un ubuntu.
#See the prefix path and compile options if edits are needed to suit your needs.
# ripped from https://gist.github.com/Brainiarc7/3f7695ac2a0905b05c5b
# updated to my personal needs
# tested on Ubuntu 22
# refer here:
@bootrino
bootrino / gist:2ed0b317913960578697499c5d43bd7f
Last active June 7, 2023 21:10
Transfer Ubuntu ec2 server to Lightsail
# USE AT YOUR OWN RISK
# THIS IS FOR EXPERTS ONLY - KNOW WHAT YOU ARE DOING.
#Step 1:
Make sure old system and new system are running same OS
On both systems:
apt update
apt upgrade
#Step 2:
@bootrino
bootrino / gist:dbbdaaf36644d25e3c23e8b3c5af09a2
Last active June 7, 2023 21:10
Copy EC2 instance to Amazon Lightsail
HOW TO Copy EC2 instance to Amazon Lightsail
WARNING - this is a guide to remind myself how to do it!!!!
WARNING - I'M NOT RESPONSIBLE FOR ANYTHING YOU DO WITH THIS!
WARNING - DON'T ASK ME ANY QUESTIONS ABOUT IT.
WARNING - THIS IS NOT A TUTORIAL - I'm typing this from memory.
These steps are a good approximation of what is needed but you'll
need strong tech skills to do this. Don't do it unless you know what you are doing.
@bootrino
bootrino / gist:bc4a4b8bfe82180391904046c2c9e344
Created June 7, 2023 21:03
backup a linux machine with xz compression using all CPU cores
# compression level 9, use all cores
XZ_OPT='-T$(nproc) -9'
# J means xz compression, z means gz
NUM_THREADS=$(nproc)
sudo env "XZ_OPT=-T${NUM_THREADS} -7" tar -cvpJf /tmp/backup.tar.xz \
--exclude=/tmp/backup.tar.xz \
--exclude=/var/swap.1 \
--exclude=/proc \
--exclude=/mnt \
--exclude=/dev \
// IMPORTANT IMPORTANT IMPORTANT - SET YOUR TWITTER HANDLE IN THE NEXT LINE!
// IMPORTANT IMPORTANT IMPORTANT - SET YOUR TWITTER HANDLE IN THE NEXT LINE!
const yourTwitterHandle = "@bootrino";
// one every 10 seconds to avoid Twitter noticing
const waitTimeSeconds = 10
const sleep = async (seconds) => new Promise(resolve => setTimeout(resolve, seconds * 1000));
const main = async () => {
while (true) {
await walkTweets();
await sleep(waitTimeSeconds)
@bootrino
bootrino / gist:95fbdc42e71220da5132120d2c771fa4
Created September 24, 2022 03:37
FlexBox margin auto spacing alignment
https://www.youtube.com/shorts/jlvwSorkdIo
@bootrino
bootrino / gist:98281b60f8d855e68444d998fd9bde6a
Created September 5, 2022 23:40
JavaScript human readable date
export const timeSince = (timestamp) => {
const seconds = Math.floor((new Date() - new Date(timestamp)) / 1000);
let interval = Math.floor(seconds / 31536000);
if (interval > 1) {
return interval + " years";
}
interval = Math.floor(seconds / 2592000);
ffmpeg -i "http://example.com/chunklist.m3u8" -codec copy file.mp4
def make_slug(text, randomize=False, total_length=None):
# arbitrary
text = text[:30]
# arbitrary
length = total_length or 5
if randomize:
text += '-' + shortuuid.ShortUUID('abdcefghkmnpqrstuvwxyzABDCEFGHKMNPQRSTUVWXYZ23456789').random(length=length)
if total_length:
return slugify(text)[:total_length]
return slugify(text)
def list_to_path(path_element_list, topslash=False, tailslash=False):
# strips leading and trailing slashes from each element and returns without leading and trailing slashes i.e. 'a/b/c'
# drop empty list elements
path_element_list = [x for x in path_element_list if x]
path = '/'.join([x.strip('/') for x in path_element_list])
if topslash:
path = '/' + path
if tailslash:
path = path + '/'