Skip to content

Instantly share code, notes, and snippets.

View mc-zone's full-sized avatar
🏢
busy

mc mc-zone

🏢
busy
View GitHub Profile
@mc-zone
mc-zone / common.js
Created August 16, 2016 06:17
webpack dll issue #2876
import { libFn } from './lib';
export function commonFn(){
libFn()
}
@mc-zone
mc-zone / emoji2utf16.js
Created August 14, 2015 06:18
emoji2utf16
function emoji2utf16(point){
if( point<0x10000 ){//softbank
return unescape("%u"+point.toString(16))
}
var offset = point - 0x10000,
lead = 0xd800 + (offset >> 10),
trail = 0xdc00 + (offset & 0x3ff);
//return unescape("%u"+lead.toString(16) + "%u"+ (trail).toString(16));
return String.fromCharCode(lead) + String.fromCharCode(trail);
}
@mc-zone
mc-zone / URL addParam
Created May 22, 2015 02:48
URL addParam
function addParam(key,val,url){
var url = url || window.location.href,
hashPart = url.split('#'),
reg = new RegExp("([\?|&]"+key+"=)([^&#?]*)"),
rst = '';
if( hashPart[0].match(reg) ){
rst = hashPart[0].replace(reg, function(){
var arg = arguments;
return arg[1] + val;
}) + ( hashPart[1]? '#'+hashPart[1]: '' );
@mc-zone
mc-zone / flatten.js
Created February 7, 2015 12:45
Two-dimensional Array Flatten (二维以下数组扁平化)
function flatten(array) {
return array.length > 0 ? new Array().concat.apply([], array) : array
}
@mc-zone
mc-zone / web_worker.html
Last active August 29, 2015 14:14
Web Worker
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>web worker</title>
<script type="text/javascript">
var w = new Worker('work.js');
w.onmessage = function(e){
console.log('work said:',e.data);
};
@mc-zone
mc-zone / viewport.js
Last active August 29, 2015 14:14
Get Viewport Size
function getViewportSize(w){
w = w || window;
//w3c
if( w.innerWidth != null ){
return { w:w.innerWidth,h:innerHeight };
}
var d = w.document;