Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am caocuong2404 on github.
  • I am caocuong2404 (https://keybase.io/caocuong2404) on keybase.
  • I have a public key ASAGrF4VukD9VsnSJP5qj06RR7uYU6zn9dG34kCltoVuwwo

To claim this, I am signing this object:

@caocuong2404
caocuong2404 / ubuntu-server-setup.sh
Created November 7, 2022 02:50
Some commands help you set up the server when the first time logged
sudo apt update
sudo apt upgrade
sudo sh -c "$(curl -fsSL https://starship.rs/install.sh)" -y -f
echo 'eval "$(starship init bash)"' >> ~/.bashrc
bash
# backup files from a docker volume into /tmp/backup.tar.gz
function docker-volume-backup-compressed() {
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}"
}
# restore files from /tmp/backup.tar.gz into a docker volume
function docker-volume-restore-compressed() {
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:2}"
echo "Double checking files..."
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie ls -lh "${@:2}"
@caocuong2404
caocuong2404 / hosts.ps1
Created April 27, 2023 03:29 — forked from markembling/hosts.ps1
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {
# make dock faster
defaults write com.apple.dock autohide-delay -float 0; killall Dock
# install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> ~/.zshrc
zsh
@caocuong2404
caocuong2404 / webcryptoapi.html
Created May 12, 2023 07:29 — forked from deiu/webcryptoapi.html
Web Crypto API example: RSA keygen & export & import & sign & verify & encrypt & decrypt
<!-- MIT License -->
<html>
<head>
<script>
function generateKey(alg, scope) {
return new Promise(function(resolve) {
var genkey = crypto.subtle.generateKey(alg, true, scope)
genkey.then(function (pair) {
resolve(pair)
})
@caocuong2404
caocuong2404 / Dockerfile
Created May 22, 2023 04:30 — forked from rosskevin/Dockerfile
nginx envsubst escape $
FROM nginx:alpine
# https://thepracticalsysadmin.com/templated-nginx-configuration-with-bash-and-docker/
ENV LISTEN_PORT=80 \
NGINX_ENV=production \
SERVER_NAME=_ \
RESOLVER=8.8.8.8 \
UPSTREAM_API=api:3000 \
UPSTREAM_API_PROTO=http \
WORKDIR=/www \
@caocuong2404
caocuong2404 / nerd_fonts.md
Created June 5, 2023 03:36 — forked from davidteren/nerd_fonts.md
Install Nerd Fonts via Homebrew [updated & fixed]
// Configuration
const CONFIG = {
API_BASE_URL: "https://www.douyin.com/aweme/v1/web/aweme/post/",
DEFAULT_HEADERS: {
accept: "application/json, text/plain, */*",
"accept-language": "vi",
"sec-ch-ua": '"Not?A_Brand";v="8", "Chromium";v="118", "Microsoft Edge";v="118"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "empty",
@caocuong2404
caocuong2404 / douyin-video-metadata-downloader.js
Created March 3, 2025 08:02
Download videos and metadata from Douyin user profiles
// ==UserScript==
// @name Douyin Video Metadata Downloader
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Download videos and metadata from Douyin user profiles
// @author CaoCuong2404
// @match https://www.douyin.com/user/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=douyin.com
// @grant none
// ==/UserScript==