Skip to content

Instantly share code, notes, and snippets.

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

Duke Nguyen vanduc1102

🐛
💯 💯 💩 😆 🐢
View GitHub Profile
@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,
// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract ERC20_Token_Sample is ERC20, ERC20Burnable {
constructor() ERC20("ERC20 Token Sample1", "Sample 1") {
@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 / array.js
Last active October 2, 2023 17:35
Array Operators in JavaScript
//1. Converting Arrays to Strings
var fruits = ["Banana", "Orange", "Apple", "Mango"];
console.log(fruits.valueOf());
//output : Banana,Orange,Apple,Mango
//For JavaScript arrays, valueOf() and toString() are equal.
// join() method joins array elements into a string.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
@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 / fb-auto-like.js
Created April 15, 2017 05:28
facebook auto like, Open console with F12 and Paste the code.
var arr= Array.prototype.slice.call(document.querySelectorAll('.UFILikeLink'));
var index = 0;
setInterval(function(){
var a = arr.shift();
if(a.className.indexOf("UFILinkBright") < 0){
console.log("like : ",++index);
a.click();
}
if(arr.length == 0){
document.querySelectorAll('a.UFIPagerLink')[0].click();
@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) {