Skip to content

Instantly share code, notes, and snippets.

@crongro
crongro / gist:10708235
Created April 15, 2014 06:48
ASM Module performance test
//http://ejohn.org/blog/asmjs-javascript-compile-target/
function DiagModule(stdlib, foreign, heap) {
//"use asm";
// Variable Declarations
var sqrt = stdlib.Math.sqrt;
// Function Declarations
@crongro
crongro / index.html
Last active August 29, 2015 14:01
Circle Rolling (infinite ~)
<div id="view">
<div id="content">
<div class="original">
<div class="a">a</div>
<div class="b">b</div>
<div class="c">c</div>
</div>
<div class="addon">
@crongro
crongro / 사용자정의 Global variables 확인 방법
Created June 11, 2014 10:55
사용자정의 Global variables 확인 방법
// 초기 코드에서 이걸 계산.
this.__d = [];
for (i in window) {
this.__d.push(i);
}
//나중에 이 메소드를 실행
(function(win){
@crongro
crongro / index.html
Last active August 29, 2015 14:03
[setTimeout] mouseover 건너뛰기.
<div id="wrap"></div>
@crongro
crongro / gist:b2a22970a97f8a98acf6
Created September 7, 2014 02:59
javascript Error Handling
<html>
<body>
<div>a</div>
</body>
</html>
<script>
try {
var a;
a.push();
@crongro
crongro / index.html
Created October 12, 2014 23:55
A Pen by younjisu.
<div id="first"><span>first span</span></div>
<div id="two"></div>
@crongro
crongro / initiate variables
Last active August 29, 2015 14:12
initiate variables
function setVariables(obj) {
var o = {};
for(var myKey in obj) {
o[myKey] = document.querySelector(obj[myKey]);
}
return o;
}
var _v = setVariables({
@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;
});
@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 / 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 = ",";