Skip to content

Instantly share code, notes, and snippets.

View QuynhVir's full-sized avatar
🏠
Working from home

Vir QuynhVir

🏠
Working from home
  • Midgard
View GitHub Profile
@QuynhVir
QuynhVir / macos_change_hostname.sh
Created March 30, 2024 06:23
macOS, how to rename computer via scutil
sudo scutil --set HostName <new host name>
@QuynhVir
QuynhVir / Delay.tsx
Created March 19, 2024 06:33
Delaying React Lazy Loaded Component Import
const IndexPage = React.lazy(() =>
new Promise<{ default: React.ComponentType }>(resolve =>
setTimeout(() => {
resolve(
import('./pages/IndexPage').then(module => ({ default: module.IndexPage }))
);
}, 3000000)
)
);
@QuynhVir
QuynhVir / convert_incompatible_codecs.sh
Created December 8, 2023 13:00
The script will convert files containing the EAC3, DTS, or DTS-HD audio codecs to use the AAC codec through the AudioToolbox encoder specified as aac_at. The converted files will get the suffix -AAC_at.mkv to distinguish them from the original files
#!/bin/bash
# Function to check and convert the file if necessary
check_and_convert() {
local file=$1
[ -d "$file" ] && return # Skip directories
# Use ffprobe to get the codec type for each audio stream
codec_info=$(ffprobe -v error -select_streams a -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$file")
@QuynhVir
QuynhVir / lazy-load-puppeteer.js
Created September 17, 2023 07:04 — forked from schnerd/lazy-load-puppeteer.js
Lazy-loading content in Puppeteer
function wait (ms) {
return new Promise(resolve => setTimeout(() => resolve(), ms));
}
export default async function capture(browser, url) {
// Load the specified page
const page = await browser.newPage();
await page.goto(url, {waitUntil: 'load'});
// Get the height of the rendered page

Setup

  • Create a developer account with Apple
  • Download and install X-Code from the Apple App Store
  • Open and run X-Code app and install whatever extras it requires
  • Open the preferences pane (cmd+,)
    • click the + in the lower right corner
    • choose Apple ID
    • enter your apple ID and password
@QuynhVir
QuynhVir / hdrtosdr.sh
Created September 6, 2022 14:18 — forked from SCG82/hdrtosdr.sh
Convert HDR video to SDR with tone mapping (especially for iPhone 12)
#!/bin/bash
#************************************************
# hdrtosdr.sh *
# v1.0.0 *
# developer: SCG82 (scg082+mp4towebp@gmail.com) *
#************************************************
USAGE_S="Usage: $0 -s [start time hh:mm:ss] -e [end time hh:mm:ss] -w width -h height -p preset FILE"
USAGE="Usage (arguments are optional): $0 -s [start time hh:mm:ss] -e [end time hh:mm:ss] -w [output width] -h [output height] -p [preset: ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow,placebo] FILE"
@QuynhVir
QuynhVir / gist:c6fbcacbb68ec7f07850557143b118bf
Created December 31, 2021 04:01
Install Go on Amazon Linux ARM
wget https://go.dev/dl/go1.17.5.linux-arm64.tar.gz
sudo tar -C /usr/local/ -xzf go1.17.5.linux-arm64.tar.gz
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$GOROOT/bin
@QuynhVir
QuynhVir / nosync.sh
Created December 14, 2021 08:42
Crawl computer for node_modules, add .nosync file
find ~ -type d -name node_modules -exec touch {}/.nosync \;
@QuynhVir
QuynhVir / systemd_service_hardening.md
Created December 9, 2021 01:59 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@QuynhVir
QuynhVir / decrypt.js
Created October 1, 2021 03:05
retrieve Chrome cookies on Windows then decrypt
const dpapi = require("win-dpapi")
const sqlite3 = require("sqlite3")
const os = require("os")
const fs = require("fs")
const crypto = require("crypto")
const path =
os.homedir() + `\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cookies`
db = new sqlite3.Database(path)