Skip to content

Instantly share code, notes, and snippets.

@crongro
crongro / requestidlecallback_test.js
Last active May 12, 2017 05:58
requestidlecallback
//forked from "https://developer.mozilla.org/en-US/docs/Web/API/Background_Tasks_API"
window.requestIdleCallbackCustom = function(handler) {
let startTime = Date.now();
return setTimeout(function() {
handler({
didTimeout: false,
timeRemaining: function() {
return Math.max(0, 50.0 - (Date.now() - startTime));
}
@crongro
crongro / simplePromise.js
Created April 25, 2017 06:57
simple Promise
//SimplePromise
function SimplePromise(fn){
let resolveData = null;
let rejectData = null;
let thenCallback = null;
const resolve = function(resultData) {
resolveData = resultData;
@crongro
crongro / historyAPI.html
Last active May 22, 2023 08:44
history API Example
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<style>
h1 {
color: red;
}
@crongro
crongro / node_vimeo_db_schema_all.info
Last active April 20, 2017 09:32
node_vimeo_db_schema_all.info
+-----------------+
| Tables_in_jsman |
+-----------------+
| articles |
| movie |
| newspaper |
| user |
+-----------------+
4 rows in set (0.00 sec)
@crongro
crongro / less-webpack-conf.js
Created April 16, 2017 11:43
webpack less loader (dev and production) - Creact React App
// 1.dev.
{
test: /\.less$/,
include: paths.appSrc,
loaders: ["style", "css", "less", "postcss"]
}
//2, production
{
test: /\.less$/,
@crongro
crongro / jsondata.js
Created April 3, 2017 06:38
jsondata.js
var news = [
{
"title" : "sbs",
"imgurl" : "http://static.naver.net/newsstand/2017/0313/article_img/9054/173200/001.jpg",
"newslist" : [
"[가보니] 가상 경주도 즐기고, 내 손으로 자동차도 만들고",
"리캡차'가 사라진다",
"갤럭시S8' 출시? '갤노트7' 처리 계획부터 밝혀야",
"블로코-삼성SDS, 블록체인 사업 '맞손",
"[블록체인 톺아보기] 퍼블릭 블록체인의 한계와 프라이빗 블록체인"
@crongro
crongro / es6_weakSet.js
Created April 2, 2017 07:47
es6_weakSet
let ws = new WeakSet();
let a = [1,2,3];
ws.add(a);
console.log(ws.has(a)); //true
a = null;
console.log(ws.has(a)); //false
@crongro
crongro / es6_destructuring.js
Last active April 1, 2017 22:40
es6_destructuring
var news = [
{
"title" : "sbs",
"imgurl" : "http://static.naver.net/newsstand/2017/0313/article_img/9054/173200/001.jpg",
"newslist" : [
"[가보니] 가상 경주도 즐기고, 내 손으로 자동차도 만들고",
"리캡차'가 사라진다",
"갤럭시S8' 출시? '갤노트7' 처리 계획부터 밝혀야",
"블로코-삼성SDS, 블록체인 사업 '맞손",
"[블록체인 톺아보기] 퍼블릭 블록체인의 한계와 프라이빗 블록체인"
@crongro
crongro / es6_spread_operator.js
Created April 1, 2017 11:48
es6_spread_operator
//참조를 유지하기 때문에 이전데이터와 현재데이터는 당연히 같다.
var originData = [1,2,"foo","bar"];
var newData = originData;
console.log(originData === newData) //true
newData[0] = 3;
console.log(newData[0] === originData[0]); //true
//이전데이터와 새로운데이터간의 비교가 필요하다면, 참조를 유지하지 않고 새로운 데이터를 만들어내야 한다.
//immutable array 를 유지하는 방법.
@crongro
crongro / es6_object_enhancement.js
Last active April 1, 2017 22:23
es6_object_enhancement
const name = "nayoun";
const age = 9;
const others = {
address : "kwang myeung city",
tel : null,
height: 130
}
const data = {
name,