Skip to content

Instantly share code, notes, and snippets.

View mu-hun's full-sized avatar
๐Ÿ’ก
No sliver bullet

Mu-Hun mu-hun

๐Ÿ’ก
No sliver bullet
View GitHub Profile
@mu-hun
mu-hun / 4.1.2.js
Created September 30, 2020 05:07
YDKJS generator example
let z = 1;
function *foo() {
const x = yield 2;
z++
const y = yield (x*z)
console.log(x, y, z)
}
const it_first = foo()
@mu-hun
mu-hun / README.md
Last active October 24, 2025 04:39
์ธ์ ‘ํ•œ ํ…Œ์ŠคํŠธ ์œ ๋‹›์—๋งŒ ํ›… ์‹คํ–‰ํ•˜๊ธฐ

ํ…Œ์ŠคํŠธ ์ˆ˜๋„ ์ฝ”๋“œ

describe('root', function () {
  beforeEach(() => {
    console.log('๋ก ์ฒ˜ ์‹œ์ž‘')
    startApp()
  })
  afterEach(() => {
    console.log('๋ก ์ฒ˜ ์ข…๋ฃŒ')
@mu-hun
mu-hun / daum-mail.js
Last active August 15, 2020 07:27
๋ถ๋งˆํฌ ํ•œ ๋ฉ”์ผ๋งŒ ์ œ์™ธํ•ด์„œ ์‚ญ์ œํ•˜๊ธฐ
const bookmark = '.btn_important.on'
const interval = setInterval(function () {
const items = document.querySelectorAll('.mail_item')
for (const item of items) {
if (item.querySelector(bookmark) == null) item.querySelector('#mCk').click()
}
document.querySelector('.btn_del').click()
if (
document.querySelector('.info_none') != null ||
const fetchMachine = Machine({
initial: 'idle',
states: {
idle: {
on: {
SUBMIT: 'submit',
},
},
submit: {
on: {
@mu-hun
mu-hun / fibonacciLoop.js
Last active May 21, 2020 13:20
Implement fibonacci with Bottom-Up Style
function fib(n) {
let first = 1, second = 0;
let current;
for (let i = 2; i <= n; i++) {
current = first + second
second = first
first = current
}
return current
}
function nextPermutation(A: number[]) {
let i = A.length - 1
let j = A.length - 1
while (i > 0 && A[i - 1] >= A[i]) i -= 1
if (i === 0) return false
while (A[j] <= A[i - 1]) j -= 1
@mu-hun
mu-hun / string_number.ts
Created May 14, 2020 03:15
string to number or number to string
function strToint(string: string) {
let i = 0;
let num = 0;
let isNeg = false;
const length = string.length;
const zeroCode = '0'.charCodeAt(0);
if (string[0] === '-') {
isNeg = true;
i = 1;
const isEqual = <T extends number | string>(first: T[], second: T[]) =>
first.length === second.length &&
first.findIndex((item, index) => item !== second[index]) === -1;
const isEqualVariableArray = <T>(...arrays: T[][]) => arrays.slice(0, arrays.length - 1).findIndex((array, index) => !isEqual<T>(array, arrays[index+1]))
console.assert(isEqualVariableArray<number>([1, 2], [1, 2], [1, 2]))
function selectionSort(array: number[]) {
for (let last = array.length - 1; last > 0; last--) {
const largest = array.slice(0, last + 1).sort()[last];
const largestIndex = array.findIndex((item) => item === largest);
array[largestIndex] = array[last];
array[last] = largest;
}
return array;
}
@mu-hun
mu-hun / ํ•™๊ต์ƒํ™œ ์† ๋ถˆํŽธํ•จ ์ค„์ด๊ธฐ.md
Last active October 24, 2025 08:43
๋งˆ์ดํฌ๋กœ์†Œํ”„ํŠธ์›จ์–ด 399ํ˜ธ โ€œ์ž๋™ํ™”์˜ ๊ด‘์‹œ๊ณกโ€ โ€” โ€œํ•™๊ต ์ƒํ™œ ์† ๋ถˆํŽธํ•จ ์ค„์ด๊ธฐโ€, 2020.01, ๊ฐœ์ • 2ํŒ โ†’ https://www.frontend.moe/posts/maso-399/

ํ•™๊ต์ƒํ™œ ์† ๋ถˆํŽธํ•จ ์ค„์ด๊ธฐ

์œ ์ € ์Šคํฌ๋ฆฝํŠธ์—์„œ ์„œ๋น„์Šค ์ œ์ž‘๊นŒ์ง€

์ฃผ๋‹ˆ์–ด ์ธํ„ฐ๋ ‰์…˜ ๋งˆ๋ฒ•์‚ฌ. ์ ๋‹นํ•œ ๋ฒ„์ „ ๊ด€๋ฆฌ ํ”„๋กœ๊ทธ๋žจ์„ ์ฐพ๋‹ค๊ฐ€ ๊นƒ(Git)์„ ๋‹ค๋ฃจ๊ฒŒ ๋˜๋ฉด์„œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ํ•„์—ฐ์ ์œผ๋กœ ์‹œ์ž‘ํ–ˆ๋‹ค.

์ƒˆ ํ•™๊ธฐ๋งˆ๋‹ค ์–ด๋–ค ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•  ์ง€ ์‹ฌ๊ฐํ•˜๊ฒŒ ๊ณ ๋ฏผ์„ ํ•˜๊ณ  ์žˆ๋‹ค.

์œ ์ € ์Šคํฌ๋ฆฝํŠธ ์†Œ๊ฐœ