Skip to content

Instantly share code, notes, and snippets.

View huynhsamha's full-sized avatar

Ha huynhsamha

  • Ho Chi Minh, Vietnam
View GitHub Profile
@huynhsamha
huynhsamha / README.md
Created September 14, 2021 01:21
Sync Netbeans JAR dependencies (nbproject/project.properties) to VSCode Reference Libs (.vscode/settings.json)

How to use ?

.vscode
├── settings.json          # list referenced libraries for VSCode
└── sync.js                # script to sync, run ./sync.js - require node
nbproject
├── build-impl.xml
├── configs
├── genfiles.properties
@huynhsamha
huynhsamha / typescript-recursive-sort.ts
Created March 18, 2020 14:52
Recursive sort in typescript
// Playground: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=39&pc=1#code/MYGwhgzhAEB2D2ATAptA3gWAFDV9C8ATgC4DyhKhAXHAK4C2ARsoQNzZ7QDCAFgJYhEhZLBoIUAbQC67LBzzB4sCMUK1gxIgAoCJcpTENmhAJTp5nXMX4QAdLrIUW0ALz4ijyrMt5rfO7wCQiKu0NIW0AC+2NFyWIrKxNCK9AAOYIRgmoShWmBiSMgANNCMBShmLgB85jh4fABm0Hm2gYLCsNAAZF3QYK387SK2ICIA5tbQNQCMZph1Pv1twbD2Hlop6ZnZJhGxnI3NjANBHd29x8sdI+OTM3MRnJeDK2skG-BpGVlEuwtREWExFohE6-Qc+mcAFpSm9PCxZLFsNgEipki8IOVkNJQtJZA0iM1Rkk+KEAKysaCkmoABkpfChUIe-2AGNsqVoEB4WlgyAA7nBClo+CYTIjkfElGjxMhMYLJFJcTJsASclpiVTQtM6ZrafTGczOKikp03LyBTLhWKIodhdAAKTQABMrjcNMNPjgJyGpvRQQg3jw+zwMrsHK5POtWCRWFDcI+X22vwlqPgoxG8DGPMKED+QA
class node {
sortOrder: number;
Children: node[];
constructor(sortOrder: number) {
this.sortOrder = sortOrder;
this.Children = []
}
@huynhsamha
huynhsamha / example-multer-custom-error.js
Created March 17, 2020 15:36
Example for multer upload custom error handling
const express = require('express')
const multer = require('multer');
const app = express();
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'tmp')
},
filename: function (req, file, cb) {
@huynhsamha
huynhsamha / settings.json
Created February 26, 2020 02:34
VS Code - My favorite settings
{
// common settings
"window.zoomLevel": 1,
"workbench.statusBar.visible": true,
"editor.fontSize": 13,
"debug.console.fontSize": 13,
"markdown.preview.fontSize": 12,
"terminal.integrated.fontSize": 13,
"terminal.integrated.fontFamily": "Menlo for Powerline",
"workbench.startupEditor": "newUntitledFile",
@huynhsamha
huynhsamha / bitwise_database.md
Last active October 17, 2019 10:34
Bitwise in database

For a one-to-many relationship, where the “many” has a small number of known values, relationships can be stored as bitmasks in the parent table as an integer, replacing the need for an additional table.

Say we have a table Person and we’d like to know how many Continents a person has visited. We’d start by assigning each Continent an “orthogonal” bit value. In C#, an enum is a good choice for this:

[Flags]
public enum JobAdvertisingRegion
{
    NorthAmerica = 1,              // or 1 << 0
 SouthAmerica = 2, // 1 &lt;&lt; 1
@huynhsamha
huynhsamha / update-vscode.sh
Created October 10, 2019 04:13
Update VS Code [Bash]
wget https://vscode-update.azurewebsites.net/latest/linux-deb-x64/stable -O /tmp/code_latest_amd64.deb
sudo dpkg -i /tmp/code_latest_amd64.deb
@huynhsamha
huynhsamha / tar-commands.md
Created March 7, 2019 04:11
Tar commands

Create

Without compress (.tar)

tar -cvf abc.tar dir1 file1 file2 other ...
c: create
v: verbose
f: format
@huynhsamha
huynhsamha / VirtualBox 6.0 - Ubuntu Server 18.04.md
Last active January 30, 2019 07:22
Using Ubuntu Server 18.04 on VirtualBox 6.0 (Config Networking, SSH, Firewall, NGINX)

Configure Ubuntu Server 18.04 on VirtualBox 6.0

Networking

Config Host-only Network on VirutalBox

Tools -> Click to Button More -> Network -> Create new network vboxnet0:

  • Adapter: IP: 192.168.56.1
  • DHCP Server: 192.168.56.2, from 192.168.56.3 to 192.168.56.254

Config network adapter on Ubuntu Server

Add adapter before start server

@huynhsamha
huynhsamha / avd.sh
Created January 18, 2019 02:51
Open AVD - Android Emulator without Android Studio on macOS
# Android Emulator
➜ ~ cd $ANDROID_HOME
➜ sdk cd emulator
➜ emulator ./emulator -list-avds
Nexus_5X_API_28_x86
Pixel_2_XL_API_28_x86
➜ emulator ./emulator -avd Nexus_5X_API_28_x86
@huynhsamha
huynhsamha / jwt-go.go
Created January 2, 2019 08:36
jwt-go - Simple implementation of JSON Web Token in Golang with jwt-go
package main
import (
"fmt"
"time"
jwt "github.com/dgrijalva/jwt-go"
)
var jwtSecret = []byte("aewihr034v923u04912ujce092u")