Skip to content

Instantly share code, notes, and snippets.

View dunz's full-sized avatar
๐ŸŽฏ
Focusing

dunz dunz

๐ŸŽฏ
Focusing
  • Woowahan Bros
  • Seoul
View GitHub Profile
@dunz
dunz / misc.js
Last active June 14, 2020 04:39
Misc Utilities from 1loc.dev
// ์ฝ”๋“œ๊ฐ€ nodeํ™˜๊ฒฝ์—์„œ ์‹คํ–‰์ค‘์ธ์ง€ ํ™•์ธ
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
// ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰ ์ค‘์ธ์ง€ ํ™•์ธ
const isBrowser = typeof window === 'object' && typeof document === 'object';
// ์„ญ์”จ๋ฅผ ํ™”์”จ๋กœ ๋ณ€ํ™˜
const celsiusToFahrenheit = celsius => celsius * 9/5 + 32;
// ํ™”์”จ๋ฅผ ์„ญ์”จ๋กœ ๋ณ€ํ™˜
@dunz
dunz / function.js
Last active November 23, 2024 11:01
Function Utilities from 1loc.dev
// ๊ฐ’์ด ํ•จ์ˆ˜์ธ์ง€ ํ™•์ธ
const isFunction = v => [
'[object Function]',
'[object GeneratorFunction]',
'[object AsyncFunction]',
'[object Promise]'
].includes(Object.prototype.toString.call(v));
// ๊ฐ’์ด ์ œ๋„ˆ๋ ˆ์ดํ„ฐ ํ•จ์ˆ˜์ธ์ง€ ํ™•์ธ
const isGeneratorFunction = v => Object.prototype.toString.call(v) === '[object GeneratorFunction]';
@dunz
dunz / dom.js
Last active June 7, 2020 07:51
Dom Utilities from 1loc.dev
// ์š”์†Œ๊ฐ€ ์ž์†์ธ์ง€ ํ™•์ธ
const isDescendant = (child, parent) => parent.contains(child);
const div = document.createElement('div')
const h1 = document.createElement('h1')
div.append(h1)
isDescendant(h1, div)
// ์š”์†Œ๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
const hasFocus = ele => (ele === document.activeElement);
@dunz
dunz / date.js
Last active June 7, 2020 05:43
Date Utilities from 1loc.dev
// ๋‘ ๋‚ ์งœ ์‚ฌ์ด์˜ ์ฐจ์ด ์ผ ์ˆ˜ ๊ณ„์‚ฐ
const diffDays = (d1, d2) => Math.ceil(Math.abs(d1 - d2) / (60*60*24*1000));
// ๋‘ ๋‚ ์งœ ๋น„๊ต
const compare = (a, b) => a.getTime() > b.getTime();
// ๋‚ ์งœ๋ฅผ yyyy mm dd ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜
const formatYmd = date => date.toISOString().slice(0, 10);
// ์ดˆ๋ฅผ hh mm ss ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜
@dunz
dunz / object.js
Last active June 7, 2021 12:52
Object Utilities from 1loc.dev
// ๊ฐ’์ด ์ผ๋ฐ˜ ๊ฐ์ฒด์ธ์ง€ ํ™•์ธ
const isPlainObject = v => !!v && typeof v === 'object' && (v.__proto__ === null || v.__proto__ === Object.prototype);
const isPlainObject = obj => !!obj && obj.constructor === Object
// ๊ฐ’์ด ๊ฐ์ฒด์ธ์ง€ ํ™•์ธ
const isObject = v => !!v && typeof v === 'object';
// ๊ฐ์ฒด๊ฐ€ ๋น„์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
const isEmpty = obj => !!obj && obj.constructor === Object && Reflect.ownKeys(obj).length === 0;
const isEmpty = obj => JSON.stringify(obj) === '{}';
@dunz
dunz / array.js
Last active January 26, 2022 08:10
Array Utilities from 1loc.dev
// ๋ชจ๋“  ๋ฐฐ์—ด ์š”์†Œ๊ฐ€ ์ฃผ์–ด์ง„ ๊ฐ’๊ณผ ๊ฐ™์€์ง€ ํ™•์ธ
const isEqual = (arr, value) => arr.every(item => item === value);
// ๋ฐฐ์—ด์˜ ๋ชจ๋“  ํ•ญ๋ชฉ์ด ๊ฐ™์€์ง€ ํ™•์ธ
const areEqual = arr => arr.every(item => item === arr[0]);
const areEqual = arr => new Set(arr).size === 1;
// ๋ฐฐ์—ด์— ์ผ๋ถ€ ๊ธฐ์ค€๊ณผ ์ผ์น˜ํ•˜๋Š” ๊ฐ’์ด ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
const contains = (arr, predicate) => !!arr.find(predicate);
const contains = (arr, predicate) => arr.some(criteria);
@dunz
dunz / gist:afef46f8fdaf81fc64985dae22a4f9ab
Last active March 28, 2025 14:31
.zshrc ์„ค์ •ํŒŒ์ผ ( feat. alias )
# Fig pre block. Keep at the top of this file.
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && . "$HOME/.fig/shell/zshrc.pre.zsh"
# -------------------------------------------------------------------
# PATH
# -------------------------------------------------------------------
# oh-my-zs #
export ZSH=$HOME/.oh-my-zsh
# MongoDB #