Skip to content

Instantly share code, notes, and snippets.

View xgenvn's full-sized avatar

TuNA xgenvn

View GitHub Profile
@xgenvn
xgenvn / pubsub.ts
Last active June 28, 2024 09:14
PubSub with Deno
import { Hono } from "jsr:@hono/hono@^4.4.0"
import { PubSub } from "npm:@google-cloud/pubsub"
import { Buffer } from "node:buffer"
import * as queryString from "npm:[email protected]"
const pubSub = new PubSub({
projectId: Deno.env.get("PROJECT_ID"),
keyFilename: Deno.env.get("GOOGLE_APPLICATION_CREDENTIALS"),
})
@xgenvn
xgenvn / README.md
Created December 6, 2023 16:57 — forked from rubencaro/README.md
Python installation guide

Python installation guide

These are my notes, not a generic solution. They are not meant to work anywhere outside my machines. Update version numbers to whatever are the current ones while you do this.

Install asdf and its python plugin, then install Python

asdf lives in https://github.com/asdf-vm/asdf

Follow its installation instructions, which at the moment of writing were:

@xgenvn
xgenvn / README.md
Created December 6, 2023 12:20 — forked from maelvls/README.md
Ubuntu, libsecret, git-credential-helper

Dealing with secrets

GNOME comes with libsecret. You can use libsecret to store your git credentials:

sudo apt install libsecret-1-0 libsecret-1-dev libglib2.0-dev
sudo make --directory=/usr/share/doc/git/contrib/credential/libsecret
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
@xgenvn
xgenvn / sample.md
Created December 12, 2022 15:25
FFMPEG BACKGROUND VIDEO AUDIO LOOP
ffmpeg -i 20221211_074437.mp4 -stream_loop -1 -i ai_len_xu_hoa_dao_Anh_Tuyet.mp3 -shortest -map 0:v:0 -map 1:a:0 -y -c:v copy 20221211_074437_dubbed.mp4
ffmpeg -i 20221211_092532.mp4 -stream_loop -1 -i ai_len_xu_hoa_dao_Anh_Tuyet.mp3 -shortest -map 0:v:0 -map 1:a:0 -y -c:v copy 20221211_092532_dubbed.mp4
ffmpeg -i 20221211_104009.mp4 -stream_loop -1 -i ai_len_xu_hoa_dao_Anh_Tuyet.mp3 -shortest -map 0:v:0 -map 1:a:0 -y -c:v copy 20221211_104009_dubbed.mp4
@xgenvn
xgenvn / parse-xlsx.mjs
Created September 9, 2022 09:27
Parse XLSX with headers
import * as XLSX from 'xlsx/xlsx.mjs'
import * as fs from 'fs';
XLSX.set_fs(fs);
function main() {
const opts = {
}
const workbook = XLSX.readFile('excel_multiple_rows.xls', opts)
const first_ws = workbook.Sheets[workbook.SheetNames[0]];
@xgenvn
xgenvn / VirtualBox MacOS Turn off high resolution.md
Created June 17, 2022 05:58
VirtualBox MacOS Turn off high resolution

Display current settings

sudo /usr/libexec/PlistBuddy \
    -c 'print NSHighResolutionCapable' \
    /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/Info.plist

Update setting (switch off high resolution for performance)

sudo /usr/libexec/PlistBuddy \
@xgenvn
xgenvn / GUIDE.md
Created May 3, 2022 13:46
Image optimize

Resize

mogrity -resize 1024 *.jpg
mogrity -resize 1024 *.jpeg
mogrity -resize 1024 *.JPG
mogrity -resize 1024 *.JPEG
ls | grep \~ | xarg rm

Optimize JPG

@xgenvn
xgenvn / .gitignore
Created January 11, 2022 14:41 — forked from johnandersen777/.gitignore
Setting Up k3s for Serverless (knative) on a $5 DigitalOcean Droplet Using k3d
.terraform/
*.pem
*.tf
*.tfstate
*.yaml
*.backup
istio-*/
cert-manager-*/
*.swp
env
@xgenvn
xgenvn / pg dump and restore guide.md
Last active December 21, 2021 16:34
pg dump & restore

Plain text format should work

docker exec -i shared_postgres_instance pg_dump -U postgres -W scons_com_vn_production > ~/backup/scons_com_vn_production.sql
docker exec -i shared_postgres_instance psql -U postgres scons_com_vn_prod -W < ~/backup/scons_com_vn_production.sql

binary format (tar, gzip) won't work using pipe

for backup, cp from container to host

@xgenvn
xgenvn / machine.js
Last active September 17, 2021 12:06
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions