Skip to content

Instantly share code, notes, and snippets.

View fengmk2's full-sized avatar
:atom:
Coding at antgroup.com

fengmk2 fengmk2

:atom:
Coding at antgroup.com
View GitHub Profile
@fengmk2
fengmk2 / timer-benchmark.js
Created December 20, 2012 14:32
Date.now VS microtime.now()
var Benchmark = require('benchmark');
var microtime = require('microtime');
var suite = new Benchmark.Suite();
suite
.add('Date.now()', function () {
var diff1 = Date.now() - Date.now();
})
.add('microtime.now()', function () {
@fengmk2
fengmk2 / svn-to-git.md
Last active March 23, 2018 10:45
从 svn 迁移到 gitlab svn to git

从 svn 迁移到 gitlab

找出所有提交者

$ svn log --xml | grep author | sort -u | perl -pe 's/.>(.?)<./$1 = /'

手动设置对应关系 users.txt

@fengmk2
fengmk2 / router.json
Last active November 24, 2017 01:10
egg router json
[
{
"name": "home",
"methods": [
"HEAD",
"GET"
],
"paramNames": [],
"path": "/",
"regexp": "/^(?:\\/(?=$))?$/",
@fengmk2
fengmk2 / mongoskin-demo.js
Created September 5, 2011 11:29
mongoskin CRUD demo
var mongo = require('mongoskin');
var db = mongo.db('127.0.0.1:27017/test');
// create index:
// key, unique, callback
db.collection('user').ensureIndex([['name', 1]], true, function(err, replies){});
// bind method: db.user ===> db.collection('user')
db.bind('user');
@fengmk2
fengmk2 / npm-install-yarn-npminstall-next.js.md
Created August 10, 2017 03:27
Taipei: npm install VS yarn VS npminstall on next.js hello world
@fengmk2
fengmk2 / WHATWG-url.js
Created June 19, 2017 16:12
hostname from WHATWG
'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];
'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';
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
$ cd /Library/Ruby/Gems/2.0.0/gems/enclose-io-compiler-0.1.0/vendor/node-v6.8.0
@fengmk2
fengmk2 / https-cutoms-dns-lookup.js
Created September 26, 2016 11:22
custom lookup on https request
'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 September 12, 2016 10:45
get header using lower case
'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';