Skip to content

Instantly share code, notes, and snippets.

View ngnguyen1's full-sized avatar
🏠
Working from home

Nga Nguyen ngnguyen1

🏠
Working from home
  • FPT - Silicon Labs
  • Hà Nội
  • 01:31 (UTC +07:00)
  • LinkedIn in/nga-nguyen
View GitHub Profile
@ngnguyen1
ngnguyen1 / callback-example.js
Created January 6, 2024 07:29
Using Promises, Async/await to fix callback hell
function doStep1(init, callback) {
const result = init + 1
callback(result)
}
function doStep2(init, callback) {
const result = init + 2
callback(result)
}
@ngnguyen1
ngnguyen1 / review-checklist.md
Created March 29, 2020 09:36 — forked from bigsergey/review-checklist.md
Front-end Code Review Checklist

Review checklist

General

  1. Does the code work?
  2. Description of the project status is included.
  3. Code is easily understand.
  4. Code is written following the coding standarts/guidelines (React in our case).
  5. Code is in sync with existing code patterns/technologies.
  6. DRY. Is the same code duplicated more than twice?
@ngnguyen1
ngnguyen1 / base64ArrayBuffer.js
Created March 29, 2020 08:57 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@ngnguyen1
ngnguyen1 / rgb-array.js
Created October 16, 2019 02:59 — forked from henrahmagix/rgb-array.js
Get an rgb() array of any hex or rgb color.
(function() {
function getRgbArray(color, alpha) {
// Always return an array, either empty or filled.
var rgb = [];
var hex;
// Get an array of rgb(a) values.
if (color.substr(0, 1) === '#') {
/* HEX STRING */
// If the first character is # we're dealing with a hex string. Get
#!/sbin/openrc-run
depend() {
need localmount
need bootmisc
}
start() {
ebegin "Mounting chroot directories"
mount -o rbind /dev /mnt/mychroot/dev > /dev/null &
@ngnguyen1
ngnguyen1 / spacemacs-keybindings
Created May 19, 2018 02:39 — forked from adham90/spacemacs-keybindings
spacemacs keybindings that i need to learn
SPC s c remove highlight
**** Files manipulations key bindings
Files manipulation commands (start with ~f~):
| Key Binding | Description |
|-------------+----------------------------------------------------------------|
| ~SPC f c~ | copy current file to a different location |
| ~SPC f C d~ | convert file from unix to dos encoding |
| ~SPC f C u~ | convert file from dos to unix encoding |
@ngnguyen1
ngnguyen1 / font.js
Created May 18, 2018 09:46 — forked from andfinally/font.js
Cache webfont in localStorage
/**
* Adapted from https://gist.github.com/hdragomir/8f00ce2581795fd7b1b7
* This version tries to load the font from localStorage. If it's not there it simply adds a link to the stylesheet
* and ajaxes the contents in on load. This makes an extra request. But adding the stylesheet link renders quicker than
* waiting for a response to the ajax request and then injecting the contents into a style tag, hopefully minimising the
* FOUT you get when you view http://www.theguardian.com/ and http://www.smashingmagazine.com.
*/
(function () {
"use strict";
// Once cached the css file is stored on the client forever. To invalidate the cache change this URL.
@ngnguyen1
ngnguyen1 / .gitconfig
Created February 2, 2018 17:57 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
Name: hahah
Architecture: x86_64
Created: 2016/09/01 13:28 UTC
Status: Stopped
Type: persistent
Profiles: default
Log:
lxc 20160901231830.049 INFO lxc_start - start.c:lxc_check_inherited:251 - closed inherited fd 3
# iptables --list
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)