Skip to content

Instantly share code, notes, and snippets.

View the1sky's full-sized avatar

nant the1sky

View GitHub Profile
@the1sky
the1sky / Functor.js
Created June 13, 2017 17:32 — forked from CrossEye/Functor.js
First Functor Fantasy
(function(global) {
var types = function(obj) {
throw new TypeError("fmap called on unregistered type: " + obj);
};
// inefficient as hell, but as long as there aren't too many types....
global.Functor = function(type, defs) {
var oldTypes = types;
types = function(obj) {
if (type.prototype.isPrototypeOf(obj)) {
@the1sky
the1sky / react_redux_store
Created October 8, 2016 11:36
react redux store
Module.contextTypes = {store: React.PropTypes.object};
@the1sky
the1sky / node-path
Last active September 12, 2016 14:55
export PATH=$PATH:/data/work/node/bin
@the1sky
the1sky / dataURItoBlob
Created August 7, 2016 05:19 — forked from kosso/dataURItoBlob
convert base64 to raw binary data held in a string
/**
via http://stackoverflow.com/questions/4998908/convert-data-uri-to-file-then-append-to-formdata/5100158
via http://www.smartjava.org/content/face-detection-using-html5-javascript-webrtc-websockets-jetty-and-javacvopencv
**/
function dataURItoBlob(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var array = [];
for(var i = 0; i < binary.length; i++) {
@the1sky
the1sky / gaode-poitype-map.js
Created May 30, 2016 09:46
高德POI类型描述映射
module.exports = {
'100000': '住宿服务;住宿服务相关;住宿服务相关',
'100100': '住宿服务;宾馆酒店;宾馆酒店',
'100101': '住宿服务;宾馆酒店;六星级及以上宾馆',
'100102': '住宿服务;宾馆酒店;五星级宾馆',
'100103': '住宿服务;宾馆酒店;四星级宾馆',
'100104': '住宿服务;宾馆酒店;三星级宾馆',
'100105': '住宿服务;宾馆酒店;经济型连锁酒店',
'100200': '住宿服务;旅馆招待所;旅馆招待所',
'100201': '住宿服务;旅馆招待所;青年旅舍',
@the1sky
the1sky / get-bounding-rect.js
Last active May 11, 2016 09:12
兼容IE的getBoundClientRect
function getRect (element) {
var rect = element.getBoundingClientRect();
var top = document.documentElement.clientTop;
var left= document.documentElement.clientLeft;
return{
top : rect.top - top,
bottom : rect.bottom - top,
left : rect.left - left,
right : rect.right - left
}
@the1sky
the1sky / page-scrollTop.js
Last active May 11, 2016 09:12
获取页面的scrollTop
var scrollTop = window.pageYOffset //用于FF
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
see at: http://www.cnblogs.com/ckmouse/archive/2012/01/30/2332070.html
@the1sky
the1sky / encodeURL-encodeURLComponent.js
Last active March 30, 2017 18:45
difference between encodeURI and encodeURLComponent
var arr = [];
for(var i=0;i<256;i++) {
var char=String.fromCharCode(i);
if(encodeURI(char)!==encodeURIComponent(char)) {
arr.push({
character:char,
encodeURI:encodeURI(char),
encodeURIComponent:encodeURIComponent(char)
});
}
@the1sky
the1sky / centos-php.txt
Last active April 11, 2016 12:12
centos install php 5.6.7
#使用EPEL源
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
#安装第三方依赖
yum -y install gcc make gcc-c++ cpp kernel-headers.x86_64 \
libxml2-devel openssl-devel bzip2-devel libjpeg-devel \
libpng-devel freetype-devel openldap-devel postgresql-devel \
aspell-devel net-snmp-devel libxslt-devel libc-client-devel \
@the1sky
the1sky / devTools性能分析
Created December 10, 2013 07:54
devTools性能分析
DevTools性能分析文档
===============================
本文只谈性能,其它请参见[devTool][1]官方文档
dumingtan@baidu.com
----------------
###Timeline解读