Skip to content

Instantly share code, notes, and snippets.

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

Duke Nguyen vanduc1102

🐛
💯 💯 💩 😆 🐢
View GitHub Profile
@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>
@vanduc1102
vanduc1102 / api.http
Created March 2, 2022 05:20
How to upload file to PreSignedUrl with vscode REST Client
@baseUrl = {{$dotenv SERVICE_API_ENDPOINT}}
@accessToken = {{$dotenv SERVICE_API_ACCESS_TOKEN}}
### Health-check
GET {{baseUrl}}/health
### Media
### Create media upload url
## This endpoint return a JSON { data : "signedUrl" }
const NUMERALS = [
{ value: 1000000000000000000000, str: 'sextillion' },
{ value: 1000000000000000000, str: 'quintillion' },
{ value: 1000000000000000, str: 'quadrillion' },
{ value: 1000000000000, str: 'trillion' },
{ value: 1000000000, str: 'billion' },
{ value: 1000000, str: 'million' },
{ value: 1000, str: 'thousand' },
{ value: 100, str: 'hundred' },
{ value: 90, str: 'ninety' },
// AVN TOKEN
pragma solidity ^0.6.12;
// SPDX-License-Identifier: MIT
interface IERC20 {
@vanduc1102
vanduc1102 / logger.ts
Last active July 3, 2021 05:56
Winston3 Logger with custom namespace
const { LOG_LEVEL, APP_ENV } = process.env;
const logFormatter = APP_ENV === 'dev'
? format.combine(
winston.format.timestamp(),
winston.format.colorize(),
winston.format.printf((meta: any) => {
const { level, message, timestamp, namespace, stack, ...restMeta } = meta;
const displayNamespace = namespace ? `[${namespace}] -` : '';
const stackMessage = stack ? `\n${stack}` : '';
@vanduc1102
vanduc1102 / NFT.md
Created June 12, 2021 17:16
Ví dụ về NFT token

Non-fungible token ( NFT)

ERC-721 Token

NTF Websites

Beeple | The First 5000 Days