Skip to content

Instantly share code, notes, and snippets.

View rpn3319's full-sized avatar

Raymond Phu Nguyen rpn3319

  • Ho Chi Minh City, Vietnam
  • 01:53 (UTC +07:00)
  • LinkedIn in/rpn19
View GitHub Profile
@rpn3319
rpn3319 / web3-resource-collections.md
Created June 10, 2022 14:27
web3 resource collection

Writing DApps in TestRPC

  1. Set up
    • install npm install -g ethereumjs-testrpc http-server
    • install npm install solc [email protected]
  2. Writing Smartcontract & deploying code
  3. Building UI with html and js
  4. Setting npm start script "start": "node deployContract.js && http-server .",
  5. Run testrpc, then run npm start
@rpn3319
rpn3319 / css-resource-collection.md
Last active June 10, 2022 14:26
css resources collection

Standards

Snippets

Unit rem tip: Adding font size 62.5% to html to specify 1rem = 10px

Snippet

@rpn3319
rpn3319 / parse-big-file-csv-using-readline.js
Created June 10, 2022 14:09
nodejs parse big file csv using readline
console.time(__filename);
const { default: axios } = require('axios');
const fs = require('fs');
const { createInterface } = require('readline');
const file = process.argv[2];
const token = process.argv[3] || 'all';
const dateStart = process.argv[4]
? new Date(`${process.argv[4]} 0:0:0`).getTime() / 1000
: null;
@rpn3319
rpn3319 / winston-basic-usage.ts
Last active June 10, 2022 14:08
nodejs winston basic usage setup
import * as winston from 'winston';
const { combine, timestamp, prettyPrint, colorize, json } = winston.format;
export const logger = winston.createLogger({
format: combine(colorize(), json(), timestamp(), prettyPrint()),
transports: [
new winston.transports.Console({
format: winston.format.simple(),
level: 'info',
@rpn3319
rpn3319 / non-blocking-promise-loop.js
Created June 10, 2022 14:05
nodejs non-blocking promise loop
/**
* Motivation
*
* We have a very big array need to be processed in order
* with a async function and make sure that not blocking
* other process
*
* Solution
*
* Using Timers functions of Node.js
@rpn3319
rpn3319 / index_of.go
Created June 10, 2022 13:57
golang array find index
package helper
func IndexOf(input []int, search int) int {
if len(input) == 0 {
return -1
}
for i, v := range input {
if v == search {
return i
@rpn3319
rpn3319 / shuffle.go
Last active June 10, 2022 13:59
golang array shuffle
package helper
import (
"math/rand"
"time"
)
func Shuffle(arr []int) []int {
for i := len(arr) - 1; i > 0; i-- {
rand.Seed(time.Now().UTC().UnixNano())
@rpn3319
rpn3319 / docker-compose.yml
Last active May 5, 2022 16:30
start wordpress docker compose
version: "3.9"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
- ./docker/my.cnf:/etc/my.cnf
restart: always
environment:
@rpn3319
rpn3319 / collection.md
Last active June 10, 2022 14:34
nodejs useful resources collection

Knowledge

Libraries and Tools

  • nanoid, uuid: Unique string generator:
  • node-schedule: run jobs
  • concurrently: Run multi commands concurrently
  • live-server: run server with live reload capability, useful fast testing html files
version: '3'
networks:
workspaces:
driver: bridge
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.3.1
restart: always