Skip to content

Instantly share code, notes, and snippets.

View vanduc1102's full-sized avatar
πŸ›
πŸ’― πŸ’― πŸ’© πŸ˜† 🐒

Duke Nguyen vanduc1102

πŸ›
πŸ’― πŸ’― πŸ’© πŸ˜† 🐒
View GitHub Profile
@vanduc1102
vanduc1102 / GITIGNORE_GLOBAL
Created March 14, 2025 02:27
Create a global gitignore for projects
# $HOME/.gitignore_global
*~
.DS_Store
# Ignore local preferrences
**/duke-local/
@vanduc1102
vanduc1102 / migrating-docker-to-colima-guide.md
Last active September 30, 2024 10:33
Migrate to Colima to replace Docker Desktop

Remove Docker desktop

rm -rf ~/Library/Group\ Containers/group.com.docker
rm -rf ~/Library/Containers/com.docker.docker
rm -rf ~/.docker

Install docker command

@vanduc1102
vanduc1102 / clean.md
Last active August 3, 2024 08:57
MacOS cleanup folders before backup commands

Show folder size

du -hs ~/workspace

Remove folders rescurisvely

cd ~/workspace;
@vanduc1102
vanduc1102 / turn-on-off-global-protect.md
Created July 20, 2024 15:58
How to quit GlobalProtect (MacOS )

I want to quit the VPN

launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*

I want to use the VPN again

launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangp*
@vanduc1102
vanduc1102 / http-push.md
Last active June 16, 2024 09:34
How to implement http push

HTTP push, often referred to as server push, is a technique where the server sends data to the client without the client having to request it. This is typically used in real-time applications like live notifications, chat applications, and live updates. There are several ways to implement HTTP push, such as using WebSockets, Server-Sent Events (SSE), and HTTP/2 Push.

Here's an overview of these methods:

1. WebSockets

WebSockets provide a full-duplex communication channel over a single, long-lived connection. This is suitable for applications that require continuous data exchange.

Example using Node.js with the ws library:

@vanduc1102
vanduc1102 / apps-permify-Dockerfile
Last active June 1, 2024 06:22
Customize Permify image to inject PERMIFY_DATABASE_URI , Replace - in filenames with / , you will get full picture
FROM cgr.dev/chainguard/bash:latest as permify-runner
WORKDIR /app
COPY --from=ghcr.io/grpc-ecosystem/grpc-health-probe:v0.4.25 /ko-app/grpc-health-probe /usr/local/bin/grpc_health_probe
COPY --from=ghcr.io/permify/permify:v0.9.0 /usr/local/bin/permify /usr/local/bin/permify
COPY --from=cgr.dev/chainguard/curl /usr/bin/curl /usr/bin/curl
COPY apps/permify/configs configs
COPY apps/permify/scripts scripts
@vanduc1102
vanduc1102 / client.ts
Last active May 26, 2024 05:30
Permify typescript nodejs client
import getPermifyClient from "./clients/permify";
getPermifyClient()
.tenancy.list({ pageSize: 10 })
.then((response) => {
console.log(response);
});
@vanduc1102
vanduc1102 / launch.json
Created May 16, 2024 05:40
vscode launch.json for npm workspaces , apps/__all _app , packages/__ all packages __
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Current TS file",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${file}"]
},
{
@vanduc1102
vanduc1102 / generate-build-info.js
Created May 4, 2024 08:50
Create build info as json-file, you can deploy , https://example.com/build-info.json
#!/usr/bin/env node
const fs = require("fs");
const buildAt = new Date().toISOString();
const buildEnv = process.env.ENVIRONMENT;
main();
function main() {
@vanduc1102
vanduc1102 / logger.ts
Created May 2, 2024 09:26
nodejs pino typescript configuration example
// npm i -S pino
// npm i -D pino-pretty
import pino from "pino";
const { LOG_LEVEL = "debug", APP_NAME = "Web" } = process.env;
const isProduction = process.env.NODE_ENV === "production";
const logger = pino({
name: APP_NAME,