Skip to content

Instantly share code, notes, and snippets.

:atom:
Coding at yuque.com

fengmk2 fengmk2

:atom:
Coding at yuque.com
Block or report user

Report or block fengmk2

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
@fengmk2
fengmk2 / npm-install-yarn-npminstall-next.js.md
Created Aug 10, 2017
Taipei: npm install VS yarn VS npminstall on next.js hello world
@fengmk2
fengmk2 / WHATWG-url.js
Created Jun 19, 2017
hostname from WHATWG
View WHATWG-url.js
'use strict';
const URL = require('url').URL;
const Benchmark = require('benchmark');
const benchmarks = require('beautify-benchmark');
const path = require('path');
function hostname1(host) {
if (!host) return '';
return host.split(':')[0];
View https-cutoms-dns-lookup.js
'use strict';
var https = require('https');
var http = require('http');
var urllib = require('urllib');
var httpsAgent = new https.Agent({ keepAlive: true });
var agent = new http.Agent({ keepAlive: true });
// cnodejs.org => 123.59.77.142
var url = 'https://123.59.77.142';
View enclose-error.log
This file has been truncated, but you can view the full file.
npm_config_registry=https://registry.npm.taobao.org enclose-io-compiler node-v6.8.0 npminstall 2.7.0 npminstall
$ cd /var/folders/5h/x4h0t8rs6w300g_wnzbx47km0000gn/T/enclose-io-compiler/npminstall-2.7.0
$ npm install
npm WARN npminstall-2.7.0 No description
npm WARN npminstall-2.7.0 No repository field.
npm WARN npminstall-2.7.0 No license field.
$ cd /private/tmp/npminstall
Detected binaries: {"npminstall"=>"bin/install.js", "npmuninstall"=>"bin/uninstall.js", "npmupdate"=>"bin/update.js"}
Using npminstall at bin/install.js
@fengmk2
fengmk2 / https-cutoms-dns-lookup.js
Created Sep 26, 2016
custom lookup on https request
View https-cutoms-dns-lookup.js
'use strict';
const https = require('https');
const dns = require('dns');
var req = https.request({
protocol: 'https:',
host: 'r.cnpmjs.org',
lookup: function foo(host, dnsopts, callback) {
setTimeout(function() {
@fengmk2
fengmk2 / get-header.js
Created Sep 12, 2016
get header using lower case
View get-header.js
'use strict';
const Benchmark = require('benchmark');
const benchmarks = require('beautify-benchmark');
const suite = new Benchmark.Suite();
suite
.add('get header all lower case', function() {
const res = {};
res['x-frame-options1'] = 'X-Frame-Options1 value';
@fengmk2
fengmk2 / set-header.js
Created Aug 30, 2016
set header benchmark
View set-header.js
'use strict';
const OutgoingMessage = require('http').OutgoingMessage;
'use strict';
const Benchmark = require('benchmark');
const benchmarks = require('beautify-benchmark');
const suite = new Benchmark.Suite();
@fengmk2
fengmk2 / set-header.js
Created Aug 30, 2016
set header benchmark
View set-header.js
'use strict';
const OutgoingMessage = require('http').OutgoingMessage;
'use strict';
const Benchmark = require('benchmark');
const benchmarks = require('beautify-benchmark');
const suite = new Benchmark.Suite();
@fengmk2
fengmk2 / map-benchmark.js
Created May 2, 2016
Find out the faster way to create a simple map object https://cnodejs.org/topic/571e0c445a26c4a841ecbcf1
View map-benchmark.js
/**
* Copyright(c) node-modules and other contributors.
* MIT Licensed
*
* Authors:
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
*/
'use strict';
View optimized-test.js
'use strict';
// http://dev.zm1v1.com/2015/08/19/javascript-optimization-killers/?spm=0.0.0.0.Rxyzi2
function testFn(a, b) {
const c = (a || 0) + (b || 1);
return c;
}
function printStatus(fn) {
You can’t perform that action at this time.