国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。
Dockerized 实践 https://github.com/y0ngb1n/dockerized
language: node_js | |
cache: | |
# Yarn 2 does not store dependencies in node_modules anymore, at least not by default. | |
# If you are using the node-modules plugin, remove the `npm: false` line. | |
npm: false | |
# Yarn 2 caches to the local .yarn directory, not the Travis default `$HOME/.yarn` | |
directories: | |
- ./.yarn/cache |
class CircuitBreaker { | |
constructor(request) { | |
this.request = request | |
this.state = "CLOSED" | |
this.failureThreshold = 3 | |
this.failureCount = 0 | |
this.successThreshold = 2 | |
this.successCount = 0 | |
this.timeout = 6000 | |
this.nextAttempt = Date.now() |
for node in node1 node2 node3;do | |
multipass launch -n $node | |
done | |
# Init cluster on node1 | |
multipass exec node1 -- bash -c "curl -sfL https://get.k3s.io | sh -" | |
# Get node1's IP | |
IP=$(multipass info node1 | grep IPv4 | awk '{print $2}') |
// 1. Server | |
// node index.js | |
// | |
// 2. Client | |
// 1) Start | |
// telnet localhost 3001 | |
// | |
// 2) Quit | |
// Click Ctrl + ], then Ctrl + C |
国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。
Dockerized 实践 https://github.com/y0ngb1n/dockerized
import { Request, Response } from 'express'; | |
import { Body, Controller, Post, Req, Res } from '@nestjs/common'; | |
import { UserService } from './user.service'; | |
import * as Redis from 'ioredis'; | |
import { RateLimiterRedis } from 'rate-limiter-flexible'; | |
const redisClient = new Redis({enableOfflineQueue: false}); | |
const maxWrongAttemptsByIPperDay = 100; | |
const maxConsecutiveFailsByUsernameAndIP = 5; |
import { map, delay } from 'rxjs/operators'; | |
import { TestScheduler } from 'rxjs/testing'; | |
import { Action } from 'redux'; | |
import { Epic, ofType, ActionsObservable, StateObservable } from 'redux-observable'; | |
const scheduler = new TestScheduler((actual, expected) => { | |
if (JSON.stringify(actual) !== JSON.stringify(expected)) { | |
throw new Error(`Failing test | |
actual: ${JSON.stringify(actual, null, 2)} |
React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.
Table of Contents
React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.
React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".
With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.