Skip to content

Instantly share code, notes, and snippets.

💭
踩坑...

Heaven NE-SmallTown

Block or report user

Report or block NE-SmallTown

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@NE-SmallTown
NE-SmallTown / index.md
Created Oct 24, 2018 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom
View index.md
@NE-SmallTown
NE-SmallTown / index.md
Created Oct 24, 2018 — forked from bvaughn/index.md
Interaction tracing with React
View index.md

Interaction tracing with React

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.

This Gist provides some high-level docum

@NE-SmallTown
NE-SmallTown / algebraic-effects-series-2.md
Created Sep 23, 2018 — forked from yelouafi/algebraic-effects-series-2.md
Capturing continuations with Generators
View algebraic-effects-series-2.md

Algebraic Effects in JavaScript part 2 - Capturing continuations with Generators

This is the second part of a series about Algebraic Effects and Handlers.

Note: initially I planned a 3-part series, but since the current post on undelimited continuations ended up taking

@NE-SmallTown
NE-SmallTown / delimited-continuations.js
Created Sep 10, 2018 — forked from yelouafi/delimited-continuations.js
delimited continuations using javascript generators
View delimited-continuations.js
// We model the call stack using a linked list of Generators
// Each Generator has a _return field pointing back to its parent
function stepGen(gen, arg) {
const {done, value} = gen.next(arg)
if(done) {
if(gen._return) {
stepGen(gen._return, value)
}
@NE-SmallTown
NE-SmallTown / prepack-gentle-intro-1.md
Created May 10, 2018 — forked from gaearon/prepack-gentle-intro-1.md
A Gentle Introduction to Prepack, Part 1
View prepack-gentle-intro-1.md

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
View string.md

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@NE-SmallTown
NE-SmallTown / bookmarklet
Created Mar 27, 2018 — forked from kentcdodds/bookmarklet
activeElement logger bookmarklet
View bookmarklet
javascript:(function(){if(window._activeElInterval){clearInterval(window._activeElInterval);delete window._activeElInterval;}else{var activeEl;window._activeElInterval=setInterval(function(){var currentActiveEl=document.activeElement;if(currentActiveEl!==activeEl){activeEl=currentActiveEl;console.log(activeEl);}},200);}})();
@NE-SmallTown
NE-SmallTown / apache-preconnect-workaround-README
Created Feb 14, 2018 — forked from eqhmcow/apache-preconnect-workaround-README
version 2 of a script to kill apache 1.3 / 2.x prefork httpd processes serving preconnect connections, in an attempt to prevent chrome from causing a DoS against the httpd
View apache-preconnect-workaround-README
script to kill apache 1.3 / 2.x prefork httpd processes serving preconnect connections, in an attempt to prevent chrome from causing a DoS against the httpd
This is version 2 of https://gist.github.com/eqhmcow/4774549
The major change is the use of two processes instead of one:
One process makes server-status requests, the other kills idle prefork processes.
This allows the kill script to continue killing idle processes even when Chrome has effectively DoS'd the apache server. When this happens, the check script can't get an updated status response back immediately, but the kill script can hopefully free up a slot by killing some processes. Having an uninterrupted request in the socket queue allows us to get an updated response after killing the Chrome preconnections are killed.
@NE-SmallTown
NE-SmallTown / firefoxBackgroundBug.html
Created Jan 22, 2018 — forked from cburgmer/firefoxBackgroundBug.html
Workaround for bug in Firefox when rendering background images in HTML to a canvas
View firefoxBackgroundBug.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test case for bug in Firefox where a background image in a SVG isn't rendered to the canvas unless a workaround is applied</title>
</head>
<body>
<canvas id="canvas" style="border:1px solid black;" width="200" height="200"></canvas>
<script type="text/javascript">
var canvas = document.getElementById("canvas"),
@NE-SmallTown
NE-SmallTown / user-timing-rum.js
Created Jan 21, 2018 — forked from pmeenan/user-timing-rum.js
Support routine for adding W3C user timing events to a site. Includes some basic polyfill support for browsers that don't support user timing or navigation timing (though the start time for non-navigation timing support could be improved with IE < 9 to use IE's custom start event).
View user-timing-rum.js
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
You can’t perform that action at this time.