https://github.com/shuhei/axios/commit/b13cc2bc7b36bc6b653cba4005580f1845550564
$ yarn test
// Recursive | |
function replaceText(node, from, to) { | |
switch (node.nodeType) { | |
case Node.TEXT_NODE: | |
node.textContent = node.textContent.replace(from, to); | |
break; | |
case Node.ELEMENT_NODE: | |
for (const childNode of node.childNodes) { | |
replaceText(childNode, from, to); | |
} |
public class Main { | |
public static void main(String[] args) { | |
System.out.println(Integer.MIN_VALUE); // -2147483648 | |
System.out.println(Integer.MAX_VALUE); // 2147483647 | |
System.out.println(Integer.MAX_VALUE + 1); // -2147483648 | |
System.out.println(-Integer.MIN_VALUE); // -2147483648 | |
System.out.println(-(Integer.MIN_VALUE + 1)); // 2147483647 | |
} | |
} |
Create a key pair.
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \
-keyout localhost-privkey.pem -out localhost-cert.pem
Run the server.
const { promises: fs } = require("fs"); | |
const textile = require("textile-js"); | |
const prettier = require("prettier"); | |
const path = require("path"); | |
async function main() { | |
const postsDir = path.resolve("source", "_posts"); | |
const files = (await fs.readdir(postsDir)).filter(file => | |
file.endsWith(".textile") | |
); |
const doors = [0, 1, 2]; | |
const tries = 100000; | |
let pickHasCar = 0; | |
let theOtherHasCar = 0; | |
for (let i = 0; i < tries; i++) { | |
const car = doors[random(3)]; | |
const pick = doors[random(3)]; | |
// Open a door that doesn't have the car. |
const React = require("react"); | |
const { mount } = require("enzyme"); | |
// A custom hook to test | |
function useCounter(initial) { | |
const [count, setCount] = React.useState(initial); | |
const increment = React.useCallback(() => setCount(c => c + 1), []); | |
const reset = React.useCallback(() => setCount(initial), [initial]); | |
return { count, increment, reset }; | |
} |
Not much difference...
default: chunkSize 16KB, hwm: 16KB x 20.80 ops/sec ±1.65% (51 runs sampled)
chunkSize 128KB, hwm: 16KB x 22.86 ops/sec ±1.07% (55 runs sampled)
chunkSize 128KB, hwm: 128KB x 21.54 ops/sec ±8.46% (52 runs sampled)
chunkSize 16KB, hwm: 128KB x 21.48 ops/sec ±1.87% (52 runs sampled)
Fastest is [ 'chunkSize 128KB, hwm: 16KB', 'chunkSize 128KB, hwm: 128KB' ]
This is a somewhat evil restaurant. When it has available seats, customers can have seats immediately and stay as long as they want. When the restaurant is full, customers need to wait on a queue. The strange thing is that new customers are led to the head of the queue. If you are the first customer who starts a queue, be prepared to wait for a long time because new customers join in front of you. And the waiter will tell you to leave the queue because you waited too long (timeout) or a new customer is joining the queue but the queue is too long (stack full)!
A demo for the race condition that can happen with a short keepAliveTimeout
Start a server:
# Start a server with 3000 ms of keepAliveTimeout
node server.js 3000
Start a client to see the race condition