Skip to content

Instantly share code, notes, and snippets.

View ChlorUpload's full-sized avatar
🌴
On vacation

Daegeon Song ChlorUpload

🌴
On vacation
View GitHub Profile
@ChlorUpload
ChlorUpload / merge.py
Created June 23, 2021 08:20
merge.py
import os
import re
import sys
from PyPDF2 import PdfFileMerger
import re
def extractNum(string):
nums = re.findall("\d+", string)
if len(nums) == 0:
return 0
@ChlorUpload
ChlorUpload / usePagination.ts
Last active August 5, 2021 17:40
pagination
type PaginationRes<T> = {
length: number | null;
partialData: T[] | null;
pageInd: number;
setPageInd: (pageInd: number) => void;
refreshData: () => void;
};
function usePagination<T>(
getLength: () => Promise<number>,
@ChlorUpload
ChlorUpload / useSearch.ts
Created December 31, 2021 11:27
useSearch
import { useCallback, useEffect, useMemo, useState } from "react";
import { useSearchParams } from "react-router-dom";
export type UseSearchRes<QueryT, ResultT> = {
query: QueryT;
results: ResultT[] | null;
loadMore: () => Promise<boolean>;
navigateSearch: (query: Partial<QueryT>) => void;
isSearching: boolean;
canLoadMore: boolean;
@ChlorUpload
ChlorUpload / useDoubleBackExit.ts
Created February 11, 2022 16:06
react-navigation extension custom hook that enables a certain route to exit the app when back button is pressed twice.
import { NavigationProp, useNavigation } from '@react-navigation/native';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
BackHandler,
AppState,
AppStateStatus,
Platform,
ToastAndroid,
} from 'react-native';
@ChlorUpload
ChlorUpload / jp_my_best_vocals.yml
Last active July 22, 2022 00:32
jp_my_best_vocals
FemaleVocals:
- Yanaginagi:
- Feel so good
- Chelly (EGOIST):
- Planetes
- Eiyuu unmei no uta
- All alone with you
- Zutomayo (Zuttomayonakadeiinoni)
- Kan saete kuyashiiwa
- Haze haseru haterumade
interface IBatterySize {
do(a: string, b: number): void;
}
class AA implements IBatterySize {
do(a: string, b: number) {}
}
class AAA implements IBatterySize {
do(a: string, b: number) {}
import os
import sys
original = sys.argv[1]
dest = sys.argv[2]
txt = sys.stdin.read()
txt = txt.replace(original, dest)
@ChlorUpload
ChlorUpload / vigenere.ts
Created September 7, 2022 15:01
vigenere cipher
/**
* alphabet order
*/
const alphabet = "abcdefghijklmnopqrstuvwxyz";
const alphabetOrderMap = new Map([...alphabet].map((c, i) => [c, i]));
const orderAlphabetMap = new Map([...alphabet].map((c, i) => [i, c]));
/**
* utils
*/
from enum import IntEnum
class Color(IntEnum):
Red = 1,
Yellow = 2,
Blue = 3,
def rule1(pile: list[Color]) -> bool: