Skip to content

Instantly share code, notes, and snippets.

@goonoo
goonoo / gist:4975654
Created February 18, 2013 07:26
설정 객체의 단점 중 매개변수의 이름을 기억해야 한다는 것 극복 + 기본값 부여 방법
function addPerson (conf) {
var options = $.extend({
username: null,
first: null,
last: null,
birthday: new Date(1970, 1, 1),
gender: "unknown"
}, conf);
// blah blah
@goonoo
goonoo / child.html
Last active December 14, 2015 13:58
easyXDM RPC 1000회 request 테스트 브라우저별로 대략 200~500ms 나옴. (IE8/10, Chrome 25에서 테스트) flash socket으로 통신하는 IE7에서는 cnt === 128 지점에서 경고없이 정지됨. 100회로 바꿔 테스트 결과 50ms 이내. 결론: RPC request 자체는 회당 1ms 미만으로 저렴. 128회 이상 연속처리 시 IE7 문제 유발 가능.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>easyXDM test</title>
</head>
<body style="background-color:red">
<div id="wrap">
<button id="start">Start</button>
<span id="result"></span>
@goonoo
goonoo / cdata_in_xhtml.html
Created March 14, 2013 05:09
avoid XHTML validation error in script element using CDATA section
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CDATA section in XHTML</title>
<script type="text/javascript">
// <![CDATA[
function t(a, b) {
return (a == 1 && b == 2);
}
@goonoo
goonoo / blind.css
Created May 6, 2013 06:56
VoiceOver 등 모든 스크린리더에서 읽어주는 방식의 요소 숨기기 (참고: http://snook.ca/archives/html_and_css/hiding-content-for-accessibility)
.blind {
position: absolute !important;
height: 1px; width: 1px;
overflow: hidden;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
@goonoo
goonoo / clear.css
Created August 1, 2013 04:25
CSS code to clear float
/* old IE(~7) clearing float */
.clear{*zoom:1}
/* modern browser include IE(8~) clearing float */
.clear:after{content:" ";display:block;clear:both}
var async = {
map: function (arr, iterator, callback) {
throw "IMPLEMENT ME PLZ"
},
mapSeries: function (arr, iterator, callback) {
throw "IMPLEMENT ME PLZ"
}
};
var test_arr = [1,2,3,4,5,6,7,8,9,0];
@goonoo
goonoo / reset.styl
Last active August 29, 2015 14:04
super simple reset stylesheet in stylus format
body
margin 0
padding 0
background #fff
color #000
font 12px/1.2 sans-serif
form, fieldset, h1, h2, h3, ul, ol, li, p, button, input, textarea, dl, dt, dd
margin 0
padding 0
@goonoo
goonoo / md5.js
Created August 18, 2014 06:00
Simple node.js md5 example
require('crypto').createHash('md5').update(STRING_TO_BE_HASHED).digest("hex")
@goonoo
goonoo / number_format.coffee
Created September 3, 2014 08:34
super simple number format includes decimal point
number_format = (num) -> return String(num).replace(/(\d)(?=(\d{3})+\b)/g,'$1,')
@goonoo
goonoo / thisplus.coffee
Last active August 29, 2015 14:06
bind this on coffeescript class
async_call = (callback) ->
setTimeout callback, 1
class ThisPlus
# 생성자
constructor: ->
# javascript의 this.do_something과 동일
@do_something()
callback = => # => 를 통해 내부 함수에 this를 binding
@do_something()