Skip to content

Instantly share code, notes, and snippets.

View zlrlo's full-sized avatar
๐Ÿฅ

jieunee zlrlo

๐Ÿฅ
  • Seoul, Republic of Korea
View GitHub Profile
@zlrlo
zlrlo / makeCompany.js
Created November 21, 2022 01:25
javascript trick - ๊ฐ์ฒด ๋ณ‘ํ•ฉ
const makeCompany = (showAddress) => {
return {
name: 'Cobalt. Inc.',
...showAddress && { address: 'Seoul' }
}
};
@zlrlo
zlrlo / uniqueNamesWithSpread.js
Created November 15, 2022 09:52
javascript trick - ๋ฐฐ์—ด ์ค‘๋ณต ์ œ๊ฑฐ
const names = ['Lee', 'Kim', 'Park', 'Lee', 'Kim'];
const uniqueNamesWithSpread = [...new Set(names)];
@zlrlo
zlrlo / sum.js
Last active November 15, 2022 09:54
javascript trick - ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐฉ์‹ ๋ฒ”์œ„ ๋ฃจํ”„
// for (let i = 5; i < 10; i += 1) { sum += i }
const sum = Array.from(new Array(5), (_, i) => i + 5).reduce((acc, cur) => acc + cur, 0);
@zlrlo
zlrlo / swap.js
Created November 15, 2022 09:25
javascript trick - swap
let a = 5, b = 8;
[a, b] = [b, a];
@zlrlo
zlrlo / singlyLinkedList.js
Last active July 26, 2023 09:41
[JS] singlyLinkedList javascript
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
class SinglyLinkedList {
constructor() {
this.head = null;
@zlrlo
zlrlo / fetchWithTimeout.js
Last active November 15, 2022 08:58
fetch๋ฅผ ํ†ตํ•œ ์š”์ฒญ ์ค‘ ์˜ค๋ž˜ ๊ฑธ๋ฆฌ๋Š” ์š”์ฒญ์ผ ๊ฒฝ์šฐ timeout์„ ๋‘๊ณ  ์ค‘๋‹จ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿด ๋•Œ AbortController๋ฅผ ์ด์šฉํ•ด ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.
async function fetchWithTimeout(resource, options = {}) {
const { timeout = 8000 } = options;
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), timeout);
const response = await fetch(resource, {
...options,
signal: controller.signal
});
@zlrlo
zlrlo / pm2.md
Last active October 18, 2020 13:58
PM2 ์‚ฌ์šฉ๋ฒ•

PM2

  • PM2๋ฅผ ์ ์šฉํ•ด Node.js ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฌด์ค‘๋‹จ์œผ๋กœ ์šด์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ํด๋Ÿฌ์Šคํ„ฐ ๋ชจ๋“ˆ์„ ํ†ตํ•ด ๋‹จ์ผ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋ฉ€ํ‹ฐ ํ”„๋กœ์„ธ์Šค๋กœ ๋Š˜๋ฆด ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•œ๋‹ค.

1. ์„ค์น˜

sudo apt-get update // ์ €์žฅ์†Œ ์—…๋ฐ์ดํŠธ
npm install pm2@latest -g // pm2 ์ „์—ญ ์„ค์น˜
@zlrlo
zlrlo / nginx.md
Last active August 16, 2021 04:51
nginx ์‚ฌ์šฉ๋ฒ•

nginx

๋™์‹œ์ ‘์† ์ฒ˜๋ฆฌ์— ํŠนํ™”๋œ ์›น ์„œ๋ฒ„ ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค.

1. ์„ค์น˜(Ubuntu)

sudo apt-get update // ์ €์žฅ์†Œ ์—…๋ฐ์ดํŠธ
sudo apt-get install -y nginx // nginx ์„ค์น˜
nginx -v // nginx ๋ฒ„์ „ ํ™•์ธ
@zlrlo
zlrlo / guide.md
Last active August 15, 2021 09:40
Git ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€

๐Ÿ“Œ Git ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€ ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ

feat : ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ ์ถ”๊ฐ€
fix : ๋ฒ„๊ทธ ์ˆ˜์ •
docs : ๋ฌธ์„œ์˜ ์ˆ˜์ •
style : (์ฝ”๋“œ์˜ ์ˆ˜์ • ์—†์ด) ์Šคํƒ€์ผ(style)๋งŒ ๋ณ€๊ฒฝ(๋“ค์—ฌ์“ฐ๊ธฐ ๊ฐ™์€ ํฌ๋งท์ด๋‚˜ ์„ธ๋ฏธ์ฝœ๋ก ์„ ๋นผ๋จน์€ ๊ฒฝ์šฐ)
refactor : ์ฝ”๋“œ๋ฅผ ๋ฆฌํŽ™ํ† ๋ง
test : Test ๊ด€๋ จํ•œ ์ฝ”๋“œ์˜ ์ถ”๊ฐ€, ์ˆ˜์ •
chore : (์ฝ”๋“œ์˜ ์ˆ˜์ • ์—†์ด) ์„ค์ •์„ ๋ณ€๊ฒฝ(๋นŒ๋“œ ์—…๋ฌด ์ˆ˜์ •, ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ € ์ˆ˜์ • ๋“ฑ)

@zlrlo
zlrlo / commands.md
Last active August 30, 2022 09:09
์ž์ฃผ์“ฐ๋Š” ๋ช…๋ น์–ด ๋ชจ์Œ

๐Ÿ› ๏ธ Useful Commands

Frequently used commands. Server NVM npm yarn Git

Server(Linux)