Skip to content

Instantly share code, notes, and snippets.

VERSION=v10.15.3
DIST=linux-x64
# Step 2: install NodeJS and npm
wget https://nodejs.org/dist/$VERSION/node-$VERSION-$DIST.tar.xz
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DIST.tar.xz -C /usr/local/lib/nodejs
sudo mv \
/usr/local/lib/nodejs/node-$VERSION-$DIST \
/usr/local/lib/nodejs/node-$VERSION
@snakeneedy
snakeneedy / getUniqueTimstampAsync.js
Created May 21, 2020 04:03
Get unique timestamp as number in JavaScript.
const sleepAsync = (ms) => (new Promise((resolve) => (setTimeout(resolve, ms))));
const getUniqueTimstampAsync = (function () {
let prev;
return async function () {
let timestamp = +(new Date());
while (prev === timestamp) {
await sleepAsync(1);
timestamp = +(new Date());
}
@snakeneedy
snakeneedy / typeUtil.js
Created May 21, 2020 05:22
Type utility in JS.
const getTypeName = (o) => {
if (o === undefined) return 'undefined';
if (o === null) return 'null';
return o.constructor.name;
};
const isUndefined = (o) => (o === undefined);
const isNull = (o) => (o === null);
@snakeneedy
snakeneedy / gridCalculator.scss
Created May 25, 2020 10:08
Grid calculator for SCSS.
$maxGridWidth: 1280px;
$marginWidth: 8px;
$gutterWidth: 16px;
$numMaxColumns: 16;
$singleColumnWidth: ($maxGridWidth - $marginWidth * 2 - $gutterWidth * ($numMaxColumns - 1)) / $numMaxColumns;
@function calColumnWidth($numColumns) {
@if $numColumns <= 0 {
@return 0px;
}