Skip to content

Instantly share code, notes, and snippets.

haocong haocong

Block or report user

Report or block haocong

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
View supportsES6.js
var supportsES6 = function() {
try {
new Function("(a = 0) => a");
return true;
}
catch (err) {
return false;
}
}();
@haocong
haocong / trial.key
Created Sep 6, 2017 — forked from huqi/trial.key
Beyond Compare 4 license for Mac
View trial.key
Beyond Compare 4
Licensed to: ASIO Allsoftinone
Quantity: 1 user
Serial number: 1822-9597
License type: Pro Edition for Windows
--- BEGIN LICENSE KEY ---
H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t
View git 设置和取消代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
View Readme.md

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

@haocong
haocong / tap.js
Created Aug 1, 2017
tapping-for-quick-debugging
View tap.js
function tap(x, fn = x => x) {
console.log(fn(x));
return x;
}
@haocong
haocong / opencvCanny.cpp
Last active Jan 4, 2017
opencvCanny demo
View opencvCanny.cpp
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
IplImage* doCanny(IplImage* image_input,
double lowThresh,
@haocong
haocong / rAF.js
Created Aug 23, 2016 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
View rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@haocong
haocong / express.md
Created Aug 18, 2016 — forked from dlutwuwei/express.md
express4.2源码解析
View express.md

title: express4.2源码解析 date: 2014-05-18 15:00:50 categories: express tags: [nodejs, node, js, express]

express是nodejs平台上一个非常流行的框架,4.2.0是最新的版本,相比3.x版本优化了代码和api,去除了connect模块,自己实现了一个router组件,实现http请求的顺序流程处理,去除了很多绑定的中间件,使代码更清晰。

##1.使用express 如何使用express在官网有很好的讲解,只用experssjs实例app的几个函数,就可以构建构建web程序。

@haocong
haocong / setRetinaMeta.js
Last active Mar 11, 2016
Set document meta on retina display
View setRetinaMeta.js
var docEl = document.documentElement;
var metaEl = document.createElement('meta');
var scale = devicePixelRatio > 1 ? 0.5 : 1;
metaEl.setAttribute('name', 'viewport');
metaEl.setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no');
if (docEl.firstElementChild) {
docEl.firstElementChild.appendChild(metaEl);
} else {
var wrap = document.createElement('div');
wrap.appendChild(metaEl);
@haocong
haocong / karatsuba.js
Last active Dec 22, 2018
Karatsuba Multiplication in JavaScript
View karatsuba.js
/**
* Karatsuba Multiplication
* @param {Number} x - first number
* @param {Number} y - second number
* @return {Number} Multiply of x and y
*/
function karatsubaMulti(x, y) {
let n = Math.min(('' + x).length, ('' + y).length);
You can’t perform that action at this time.