Skip to content

Instantly share code, notes, and snippets.

@hkwon
hkwon / useCommonModal.js
Created December 3, 2019 00:51
useCommonModal.js
import React from "react";
const MODAL_CLOSED = false;
const MODAL_OPENED = true;
function useCommonModal(initialState = MODAL_CLOSED) {
const [isOpened, setIsOpened] = React.useState(initialState);
const open = () => {
setIsOpened(MODAL_OPENED);
};
const _$ = (selector, base=document) => base.querySelector(selector);
const _$$ = (selector, base=document) => base.querySelectorAll(selector);
export { _$, _$$ };
# Bootstrap 3 vs. 4
- 3은 px 단위이고 4는 em 단위
- 4에서는 old ie 버전을 지원하지 않음
- 3을 사용하는 이유는 좋은 plug-in 들이 3 기반이기 때문이었는데...
이제는 4에서도 지원함 예) summer note, sb admin
# Summer note
- 관련 css, js 선언하고
- 아래와 같이 id값을 동일하게 선언하면 됨
```
@hkwon
hkwon / Bootstrap study note
Created September 29, 2019 01:47
Bootstrap에 대해 공부한 내용 정리
Bootstrap 3 vs. 4
@hkwon
hkwon / event_bus.js
Last active October 11, 2019 06:02 — forked from PierfrancescoSoffritti/eventBus.js
A simple implementation of an event bus in Javascript. More details here: https://medium.com/@soffritti.pierfrancesco/create-a-simple-event-bus-in-javascript-8aa0370b3969
function EventBus() {
const subscriptions = { };
this.on = function subscribeCallbackToEvent(eventType, callback) {
const id = Symbol('id');
if (!subscriptions[eventType]) subscriptions[eventType] = { };
subscriptions[eventType][id] = callback;
return {
off: function off() {
delete subscriptions[eventType][id];
@hkwon
hkwon / webcam.html
Created August 3, 2019 07:56
webcam.html for Chrome
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Webcam</title>
<script>
function play() {
var video = document.querySelector('#video');
@hkwon
hkwon / Observable.js
Created July 29, 2019 02:05
Typical observable pattern in javascript
module.exports = class Observable {
constructor() {
this._observers = new Set();
}
subscribe(observer) {
this._observers.add(observer);
}
unsubscribe(observer) {
@hkwon
hkwon / sleep.js
Last active July 29, 2019 02:09
sleep() function in javascript
const util = {
sleep(ms) { // ms: milliseconds
return new Promise(resolve => setTimeout(resolve, ms));
}
};
module.exports = util;