Skip to content

Instantly share code, notes, and snippets.

View devheedoo's full-sized avatar
☺️
React + TypeScript

heedo devheedoo

☺️
React + TypeScript
  • Growdle
  • Seoul, South Korea
View GitHub Profile
@devheedoo
devheedoo / useHashModal.ts
Created July 7, 2025 09:35
open/close modal using hash in React App
import { useEffect, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
export function useHashModal(hash: string) {
const location = useLocation()
const navigate = useNavigate()
const [isOpen, setIsOpen] = useState(location.hash === hash)
// 감시: 해시 바뀌면 열림/닫힘 상태 업데이트
useEffect(() => {
@devheedoo
devheedoo / colorByDepthFromSelector.js
Created July 7, 2025 04:13
Color DOM elements for markup tasks
(function colorByDepthFromSelector() {
// 64개의 서로 다른 색상 생성
function generateColors() {
const hues = [0, 30, 60, 120, 180, 210, 270, 300]; // red, orange, yellow, green, cyan, blue, purple, pink
const lightnessSteps = [95, 90, 85, 80, 75, 70, 65, 60]; // 밝기 조절
const colors = [];
for (const h of hues) {
for (const l of lightnessSteps) {
colors.push(`hsl(${h}, 70%, ${l}%)`);
@devheedoo
devheedoo / overrideBrowserDate.js
Last active July 2, 2025 23:49
Override browser date for testing or something
(() => {
const dayDiff = 2
const offsetMs = dayDiff * 24 * 60 * 60 * 1000; // 이틀 = 2일 * 24시간 * 60분 * 60초 * 1000ms
const futureTime = Date.now() + offsetMs;
const OriginalDate = Date;
class MockDate extends OriginalDate {
constructor(...args) {
if (args.length === 0) {
return new OriginalDate(futureTime);
@devheedoo
devheedoo / vscodeSettingsChoco.json
Last active December 14, 2021 19:54
Personal VSCode settings
{
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "Hack",
"terminal.integrated.defaultProfile.osx": "zsh",
"editor.minimap.enabled": false,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"typescript.preferences.quoteStyle": "single",
"javascript.preferences.quoteStyle": "single",
"editor.defaultFormatter": "esbenp.prettier-vscode",
git branch | tr -s '\n' ' ' | tr -s '*' ' ' | xargs git branch -D
const likedVideoElements = document.querySelectorAll('ytd-playlist-video-renderer.ytd-playlist-video-list-renderer yt-icon.ytd-menu-renderer');
for (let i=0; i<likedVideoElements.length; i++) {
setTimeout(() => {
likedVideoElements[i].click();
setTimeout(() => { document.querySelectorAll('yt-formatted-string.ytd-menu-service-item-renderer')[3].click(); }, 200);
}, i * 500);
}
@devheedoo
devheedoo / asyncSum.js
Created August 17, 2020 23:41
sequential async sum with reduce
const numbers = [2, 5, 1, 3, 4];
function asyncNumber (n) {
return new Promise((resolve, reject) => { resolve(n) });
}
async function asyncSum (numbers) {
return numbers.reduce(async (prevSum, n) => {
const sum = await prevSum;
return asyncNumber(sum + n);
@devheedoo
devheedoo / gists.md
Created July 3, 2020 02:23
Gists while working

Gists

Temp

  • connect to media_dev: $ ssh -i ~/Downloads/blend_keypair.pem [email protected]
  • clean yarn cache: $ yarn cache clean
  • check connected android device: $ adb devices
  • build & run RN android on release version: $ react-native run-android --variant=release

Git

Install

Cocoapods

Uninstall

> sudo gem uninstall cocoapods
@devheedoo
devheedoo / exceptAge.js
Last active February 17, 2020 09:36
Get object except some properties
const obj = {
a: {id: 'aa', name: 'aaa', age: 1},
b: {id: 'bb', name: 'bbb', age: 2},
c: {id: 'cc', name: 'ccc', age: 3},
}
// get object except 'age' property
const exceptAge = ({ age, ...rest }) => rest;
R.map(exceptAge, obj);