Skip to content

Instantly share code, notes, and snippets.

View vanduc1102's full-sized avatar
🐛
💯 💯 💩 😆 🐢

Duke Nguyen vanduc1102

🐛
💯 💯 💩 😆 🐢
View GitHub Profile
@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,
@vanduc1102
vanduc1102 / app.ts
Created January 18, 2024 04:32
NextJS@13 and KoaJS@2 integration to use koajs to handle nextjs api
import Koa, { Context } from "koa";
import bodyParser from "@koa/bodyparser";
import registerRoutes from "./routers";
import Jwt from "koa-jwt";
const { THIRD_PARTY_APP_JWT_SECRET = "" } = process.env;
const koaApp = new Koa();
koaApp.use(bodyParser());
koaApp.use(async (ctx: Context, next) => {
@vanduc1102
vanduc1102 / kill-process-by-given-port
Created April 11, 2023 04:01
[MacOS] Kill process is linked to a given port , eg: 3000
ps aux | grep -i 3000 | grep -v grep | awk {'print $2'} | xargs kill -9
INSTANCE_NAME=nucleus-jumphost-570
PORT=8080
REGION=us-west4
ZONE=us-west4-a
FIREWALL_RULE=allow-tcp-rule-698
# setup
gcloud config set compute/zone $ZONE
gcloud config set compute/region $REGION
@vanduc1102
vanduc1102 / HOFSampleToro.java
Created October 6, 2022 17:02
Java Higher Order Function sample
package com.pragmatists.blog.events.application;
import java.util.Random;
import java.util.function.Function;
import java.util.function.Supplier;
public class HOFSampleToro {
public static void main(String[] args) {
@vanduc1102
vanduc1102 / spotless-pom.xml
Last active August 9, 2022 07:43
google code format with spotless
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.24.0</version>
<configuration>
<formats>
<format>
<includes>
<include>*.md</include>
<include>.gitignore</include>