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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://unpkg.com/jest-expect-standalone@latest/dist/expect.min.js"></script>
<script src="https://unpkg.com/redux@4.0.1/dist/redux.js"></script>
<title>JS Bin</title>
</head>
<body>
@CuongNgMan
CuongNgMan / JS code snippet
Last active June 29, 2020 05:33
JS snippet
{
// Place your snippets for javascriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",

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
@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",
@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 / 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|
" 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 / 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:

{
"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 / 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),