Skip to content

Instantly share code, notes, and snippets.

View ngnguyen1's full-sized avatar

Nga Nguyen ngnguyen1

  • FPT - Silicon Labs
  • Hà Nội
  • 11:58 (UTC +07:00)
  • LinkedIn in/nga-nguyen
View GitHub Profile
#!/sbin/openrc-run
depend() {
need localmount
need bootmisc
}
start() {
ebegin "Mounting chroot directories"
mount -o rbind /dev /mnt/mychroot/dev > /dev/null &
@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
@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 / 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 / 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)
}