I hereby claim:
- I am cramhead on github.
- I am marcdentremont (https://keybase.io/marcdentremont) on keybase.
- I have a public key ASCDthhnXfGUSAeNLgPUxtemb25OPFR_QrgF5ztWaE633go
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Prints nested arrays as one string. Handy for Quokka.js | |
``` | |
function printNestedArray(arr, depth = 0) { | |
let result = '' | |
const indent = ' '.repeat(depth)); | |
if (Array.isArray(arr)) { | |
result = result + `\n${indent}[` | |
for (const item of arr) { |
INSERT INTO user (id, uid) VALUES (1, 'uid1'), (2, 'uid2'), (3, 'uid3') ON DUPLICATE KEY UPDATE id=VALUES(id), uid=VALUES(uid); |
Temporal Dead Zone: term that expresses that time between which a variable is available due to it being in a valid scope and exists, i.e. is declared.
Early Activation: When a function expression has not yet been defined it can still be referenced, as long as it's not called.
Function Hoisting: All functions are available to be called when entering a scope where they are defined; as if they were hoisted to the top of the scope
Bound Variables: Variables associated with scope, e.g. parameters and local variables
Free Variables: Variables available via the enclosing environment. For example, a A function can define another function B within it. The variables defined in A, available in B.
Variables don't put space before or after = sign. Otherwise, it expects the next thing is a command, e.g. a=1 sleep 1; echo a is $a
# a is visible to the sleep command
Special chars, e.g. a space, need quotes around them, e.g. echo "some stuff"
set value at time of declaration. Use unset
to remove it. Prefix with $ to get value
export myvar=10 # export puts the variable in your environment
declare -x mysecondvar=20
export -f myfunc # exports a function
echo myvar is $myvar and mysecondvar is $mysecondvar #myvar is 10
scripts": {
"start": "node --debug ."
}
Dockerfiles describe how to build docker images
docker build -t tagName .
build an image from the dockerfile in the current folder and call is tagName
Each line make a new image that is used in the subsequent step. So if your program downloads a big file then the next line only uses a small bit of it the image will include the big image. Otherwise, if your program downloaded a big image and used a small bit of it on the same line the image only includes the small bit. Much better
Previous image is not modified. So if there is no change that step is not rerun. Put the parts of the code that change the most at the end of the docker file so you can leverage this feature. Note, if you want to redo an part of the code, where things didn't change, you must tell docker as it will otherwise skip it
"build": "webpack --mode production" |
"start": "node dist/main.js" |
const nodeExternals = require('webpack-node-externals') | |
module.exports = { | |
target: 'node', | |
externals: [nodeExternals()] | |
}; |