Skip to content

Instantly share code, notes, and snippets.

@crongro
crongro / wsclient.html
Created December 11, 2015 05:10
websocket client ex
<html>
<head>
<style>
#log{
width : 600px;
height : 400px;
border : 1px solid red;
margin-bottom : 10px;
}
</style>
@crongro
crongro / debug.js
Created October 13, 2015 05:41
debugError
function execCalc(aData) {
var nMin = Number.MAX_VALUE;
var nMax = Number.MIN_VALUE;
for(var i = 0 ; i < aData.length; i++) {
if(aData[i] < nMin) {
nMin = aData[i];
}else if(aData[i] > nMax) {
nMax = aData[i];
}else{}
@crongro
crongro / advanced.css
Last active October 20, 2015 09:02
ADVANCED
header,nav,section,div,footer,ul,dd {margin:0;padding:0;}
li{list-style: none;}
dt {
font-weight: bold;
font-size: 1.2em;
margin-bottom: 5px;
}
dl {
float: left;
@crongro
crongro / test.html
Last active September 11, 2015 04:55
In System.js, react module unit test using Qunit
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>qunit test</title>
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css"/>
</head>
<body>
<div id="qunit"></div>
@crongro
crongro / 0316_2
Created March 16, 2015 11:42
0315_2
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>testcode</title>
<style type="text/css" media="screen">
.testButton{width:400px;height:50px;}
.showLayer{width:400px;height:400px;background:pink}
.showLayer > div {padding: 10px; box-sizing: border-box; }
</style>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>testcode</title>
<style type="text/css" media="screen">
.testButton{width:400px;height:50px;}
.showLayer{width:400px;height:400px;background:pink}
.showLayer > div {padding: 10px; box-sizing: border-box; }
</style>
@crongro
crongro / compare Array using Join Function
Created February 2, 2015 01:04
compare Array using Join Function
var a = [1,2,3,4,5];
var b = [1,2,3,4,5];
a === b //false
a.join('_') === b.join('_'); //true
@crongro
crongro / JavaScript Inheritance (light version)
Created February 1, 2015 06:00
JavaScript Inheritance (light version)
//thin 'Object.create()'
function JClass(parentProto) {
var fun = new Function();
fun.prototype = parentProto;
return new fun();
}
// Parent function
function ESS(name) {
this.comma = ",";
@crongro
crongro / 'handlEvent'
Created January 29, 2015 04:45
attach Events using 'handlEvent'
function TA() {
this.ele = document.querySelector("#message");
this._attachEvents();
}
TA.prototype = {
_handlers : {
click : '_clickHandler',
mousedown : '_mousedownHandler', /* test */
touchstart: '_touchHandler',/* test */
@crongro
crongro / gist:6030c194c62f9909e521
Created December 26, 2014 08:03
recursive sum using Array reduce
var arr = [1,2,3,[4,5,[4,6,[4,5,[5,[5,[6,100,[21]]]]]]]];
var result = (function getSum(arr) {
var sum = arr.reduce(function(pre,cur,i,o){
if(typeof cur !== "number") {
return pre + getSum(cur);
}
return pre+cur;
});