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: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 + '/'
@bootrino
bootrino / gist:a21f541de2a0d0bd98a5a47b5003a65c
Last active August 11, 2022 20:26
return UUID from postgres without dashes / hyphens
SELECT
createdat,
REPLACE(CAST (default_renderid AS TEXT), '-', '') as default_renderid,
paintbox_name,
teamname,
description,
title
FROM render_templates
@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:980d1825e338a483421efc6fa4064070
Created August 5, 2022 06:46
TypeScript destructure whilst ignoring null/undefined fields:
refer here:
https://www.bennadel.com/blog/3590-you-can-safely-apply-object-spread-to-null-and-undefined-values-in-typescript-3-2-4.htm