Skip to content

Instantly share code, notes, and snippets.

let elemA = document.getElementsByTagName('a');
let body = document.getElementsByTagName('body')[0];
console.log('[한번에 appendChild 해주는 경우 with fragment]')
console.time('testDocumentFragment');
fragment = document.createDocumentFragment();
for(var i = 0; i < elemA.length * 100; i++){
@JaeYeopHan
JaeYeopHan / progress-bar.jsx
Created January 18, 2019 09:51
progress bar
import React from 'react'
import { throttle } from 'lodash-es'
import './index.scss'
export class ProgressBar extends React.Component {
constructor(props) {
super(props)
this.state = {
scrollY: 0,
@JaeYeopHan
JaeYeopHan / util.scss
Created September 12, 2018 02:29
Utility of scss
// ------------------------------------- //
// Style of Utilities
// ------------------------------------- //
:global(.blind) {
font-size: 0;
height: 0;
left: 0;
line-height: 0;
overflow: hidden;
@JaeYeopHan
JaeYeopHan / externals.config.js
Created August 29, 2018 07:25
Useful external option of webpack config
externals: [
function(context, request, callback) {
if ((/packages\/[^\/]+\//g).test(context)){
if (!/^\./g.test(request)) {
console.log("exclude", request);
return callback(null, 'commonjs ' + request);
}
}
callback();
}],
@JaeYeopHan
JaeYeopHan / .zshrc
Last active November 9, 2021 12:52
My .zshrc
export ZSH=/Users/user/.oh-my-zsh
ZSH_THEME="powerlevel9k/powerlevel9k"
# ZSH_THEME="bullet-train"
# ZSH_THEME="agnosterzak"
# ZSH_THEME="agnoster"
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
@JaeYeopHan
JaeYeopHan / simple_redux.js
Created May 4, 2018 04:52
Sample code of simple redux
const counter = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
}
@JaeYeopHan
JaeYeopHan / Card.tsx
Created April 24, 2018 11:16
Example code react version to Card component in post of state management posting
class Card extends React.Component<CardProps> {
do() {
// do something...
}
render() {
const { index } = this.props;
return ( ... );
}
}
@JaeYeopHan
JaeYeopHan / Marker.ts
Last active April 24, 2018 11:10
Example code to Marker component in post of state management posting
export class Marker extends EventEmitter {
constructor(
private id: number,
) {
super();
document.querySelector("marker").addEventListener("click", () => {
// do something
this.trigger("card_action", this.id);
});
@JaeYeopHan
JaeYeopHan / store.js
Created April 20, 2018 04:56
Simple store sample code
class Store {
constructor(state = {}, actions = {}) {
this.state = state;
this.actions = actions;
this.dispatch = (action, data) => {
const newMergedData = this.actions[action](this.state, data);
Object.assign(this.state, newMergedData);
};
}
}