Skip to content

Instantly share code, notes, and snippets.

View CuongNgMan's full-sized avatar
❤️‍🔥
I may be slow to respond.

CuongNgMan

❤️‍🔥
I may be slow to respond.
  • Vietnam, Ho Chi Minh
View GitHub Profile
@CuongNgMan
CuongNgMan / readSheet.js
Created September 8, 2022 11:07 — forked from sreepurnajasti/readSheet.js
Reading xlsx, csv files using exceljs in node
var Excel = require('exceljs');
var workbook = new Excel.Workbook();
workbook.xlsx.readFile('../../storage/cust_88ae31d4-47c5-4f70-980e-7b473ba20ef9/xls.xls')
.then(function() {
var worksheet = workbook.getWorksheet('Sheet1');
worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
console.log("Row " + rowNumber + " = " + JSON.stringify(row.values));
});
});
@CuongNgMan
CuongNgMan / strong-password-regex.md
Created June 26, 2022 16:48 — forked from arielweinberger/strong-password-regex.md
Strong password Regular Expression - NestJS Course
  • Passwords will contain at least 1 upper case letter
  • Passwords will contain at least 1 lower case letter
  • Passwords will contain at least 1 number or special character
  • There is no length validation (min, max) in this regex!

Regular expression for JavaScript:

/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
@CuongNgMan
CuongNgMan / gist:3d5bc76b93b722176f0a982388a90b08
Created May 22, 2022 16:07 — forked from alexedwards/gist:dc3145c8e2e6d2fd6cd9
Example of working with Go's database/sql and NULL fields
CREATE TABLE books (
isbn char(14) NOT NULL,
title varchar(255),
author varchar(255),
price decimal(5,2)
);
INSERT INTO books (isbn, title, author, price) VALUES
('978-1503261969', 'Emma', 'Jayne Austen', 9.44),
('978-1514274873', 'Journal of a Soldier', NULL, 5.49),
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug NodeJS server",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
"envFile": "${workspaceFolder}/.env",
@CuongNgMan
CuongNgMan / jwt-expiration.md
Created October 3, 2021 07:26 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

" With this function you can reuse the same terminal in neovim.
" You can toggle the terminal and also send a command to the same terminal.
let s:monkey_terminal_window = -1
let s:monkey_terminal_buffer = -1
let s:monkey_terminal_job_id = -1
function! MonkeyTerminalOpen()
" Check if buffer exists, if not create a window and a buffer
if !bufexists(s:monkey_terminal_buffer)
@CuongNgMan
CuongNgMan / KeyMappings
Created January 24, 2021 13:16 — forked from geekontheway/KeyMappings
NerdTree
o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
O.......Recursively open the selected directory..................|NERDTree-O|
x.......Close the current nodes parent...........................|NERDTree-x|
@CuongNgMan
CuongNgMan / init.vim
Created December 24, 2020 10:40
neovim configuration
" vim:foldmethod=marker:foldlevel=0
" vim-plug {{{
call plug#begin()
" color scheme
Plug 'chriskempson/base16-vim'
" syntax highlighting
Plug 'peterhoeg/vim-qml'
@CuongNgMan
CuongNgMan / tasks.json
Created February 23, 2020 16:51 — forked from deadalusai/tasks.json
VS Code tasks.json for Rust/Cargo
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
"version": "0.1.0",
"command": "cargo",

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule