JavaScript Arrays are a very flexible data structure and used as lists, stacks, queues, tuples (e.g. pairs), etc. Some
Creating Arrays, reading and writing elements:
const server = require('./server.js') | |
const numCPUs = require('os').cpus().length | |
const cluster = require('cluster') | |
function makeCluster() { | |
return new Promise((resolve, reject) => { | |
if (cluster.isMaster) { | |
for (let i = 0; i < numCPUs; i++) { | |
cluster.fork() | |
} |
$ curl --help | |
Usage: curl [options...] <url> | |
--abstract-unix-socket <path> Connect via abstract Unix domain socket | |
--alt-svc <file name> Enable alt-svc with this cache file | |
--anyauth Pick any authentication method | |
-a, --append Append to target file when uploading | |
--basic Use HTTP Basic Authentication | |
--cacert <file> CA certificate to verify peer against | |
--capath <dir> CA directory to verify peer against | |
-E, --cert <certificate[:password]> Client certificate file and password |
#!/bin/bash | |
# file: ttfb.sh | |
# curl command to check the time to first byte | |
# ** usage ** | |
# 1. ./ttfb.sh "https://google.com" | |
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com" | |
curl -o /dev/null \ | |
-H 'Cache-Control: no-cache' \ | |
-s \ |
function asyncLoadCSS (css_href) { | |
var css_link = function () { | |
var h = document.getElementsByTagName('head')[0] | |
var l = document.createElement('link') | |
l.rel = 'stylesheet' | |
l.href = css_href | |
h.parentNode.insertBefore(l, h) | |
}, RAF = requestAnimationFrame || mozRequestAnimationFrame | |
|| webkitRequestAnimationFrame || msRequestAnimationFrame | |
if (RAF) RAF(css_link); else window.addEventListener('load', css_link) |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
server { | |
server_name youtube.flerovio.dev; | |
location @404 { | |
return 302 /sq$request_uri; | |
} | |
error_page 404 = @404; | |
location ~ /sq/(.+) { |
import { Component } from "React"; | |
export var Enhance = ComposedComponent => class extends Component { | |
constructor() { | |
this.state = { data: null }; | |
} | |
componentDidMount() { | |
this.setState({ data: 'Hello' }); | |
} | |
render() { |