Skip to content

Instantly share code, notes, and snippets.

View pocojang's full-sized avatar
🐢

Poco pocojang

🐢
View GitHub Profile
@pocojang
pocojang / .eslintrc
Last active November 20, 2017 06:42
custom eslintrc
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true,
},
@pocojang
pocojang / tsconfig.json
Last active December 1, 2017 05:44
compile options
{
"compilerOptions": {
"//": "ES2015+ 의 import * from 사용 지원",
"allowSyntheticDefaultImports": true,
"//": "ES7 데코레이터에 대한 지원 (experimental)",
"experimentalDecorators": true,
"//": "데코레이터를 사용한 DI 지원 (experimental)",
"emitDecoratorMetadata": true,
"//": "컴파일에 포함될 라이브러리 (배열로 지정해야함)",
"lib": [ "dom", "es5", "es2015", "es2015.promise" ],
@pocojang
pocojang / modulePattern.js
Created May 1, 2018 21:09
module pattern
var obj = (function() {
// 비공개
var age = 25;
return {
// 공개
name: 'hello',
getAge: function() {
return age;
},
@pocojang
pocojang / protoConstructor.js
Last active May 1, 2018 21:13
prototype & constructor
function Person(name) {
// 생성자내에서만 사용가능
var age = 30;
this.name = name;
// 인스턴스 생성시 계속 생성됨
this.greeting = function() {
return this.name;
};
var todo = (function(){
var tasks = [];
var addTask = (function(){
var id = 0;
return function(title){
var result = id;
tasks.push({id: id++, title: title, state: STATE.PROGRESS()});
render();
return result;
var Html = function(){};
Html.prototype = new Renderer();
Html.prototype._init = function(){
if(typeof this.completeLi !== 'undefined' && typeof this.progressLi !== 'undefined') {
return;
}
this.progressLi = document.querySelector('#todo .progress li');
this.completeLi = document.querySelector('#todo .complete li');
@pocojang
pocojang / s70_1_0.js
Created June 20, 2018 21:10 — forked from woowawebui/s70_1_0.js
구구단
for (var i = 1; i <= 9; i++) {
for (var j = 1; j <= 9; j++) {
console.log(i, 'X', j, '=', i * j);
}
}
eachDan(7);
for (var i = 8; i <= 18; i += 2) eachDan(i);
printDan([3, 7, 9, 13]);
@pocojang
pocojang / qs.js
Last active August 12, 2018 05:07
쿼리 셀렉터
export default function(query, target = document) {
return target.querySelectorAll(query).length > 1 ? [...target.querySelectorAll(query)] : target.querySelector(query);
}
function $(query) {
return (document.querySelectorAll(query).length >= 2
? Array.from(document.querySelectorAll(query));
: document.querySelector(query));
}
@pocojang
pocojang / config.json
Created August 12, 2018 05:39
vscode config
{
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.fontFamily": "d2coding ligature",
"editor.fontLigatures": true,
"editor.fontSize": 16,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnType": false,
"editor.insertSpaces": true,
@pocojang
pocojang / useDetectScrollEnd.js
Created June 28, 2019 01:54 — forked from almond-bongbong/useDetectScrollEnd.js
custom hook for detecting scroll end
import { useState, useRef, useEffect, useCallback } from 'react';
import throttle from 'lodash/throttle';
const useDetectScrollEnd = (endPercent = 0.9) => {
const scrollEnded = useRef(false);
const [isScrollEnd, setIsScrollEnd] = useState(false);
const handleScroll = useCallback(throttle(() => {
const { scrollY, innerHeight } = window;
const scrollPercent = (scrollY + innerHeight) / document.body.scrollHeight;