Skip to content

Instantly share code, notes, and snippets.

View hmmhmmhm's full-sized avatar
๐Ÿงฏ
BURNING!!

<hmmhmmhm/> hmmhmmhm

๐Ÿงฏ
BURNING!!
View GitHub Profile
@hmmhmmhm
hmmhmmhm / clovaTTS.ts
Created June 20, 2021 06:04
๋„ค์ด๋ฒ„ ํด๋กœ๋ฐ” TTS API ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ & ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ์‚ฌ์šฉ๋ฒ• (Naver Clova TTS API Javascript & Typescript Usage)
import axios from 'axios'
import path from 'path'
import fs from 'fs'
import querystring from 'qs'
import { Readable } from 'stream'
export const Speakers = [
/**
* ๋‹ค์ธ (์—ฌ์•„ ๋ชฉ์†Œ๋ฆฌ)
*/
@hmmhmmhm
hmmhmmhm / googleTTS.ts
Created June 20, 2021 06:30
๊ตฌ๊ธ€ TTS API ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ & ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ์˜ˆ์ œ (Google TTS API Javascript & Typescript Usage)
// How To Authentication: https://cloud.google.com/docs/authentication/getting-started#auth-cloud-implicit-nodejs
import textToSpeech from '@google-cloud/text-to-speech'
import fs from 'fs'
import util from 'util'
// Creates a client
const client = new textToSpeech.TextToSpeechClient()
const getTTSContent = async (props: {
@hmmhmmhm
hmmhmmhm / jsdomCSR.ts
Created June 20, 2021 09:41
JSDOM CSR ๋ Œ๋”๋ง ์˜ˆ์‹œ
import 'isomorphic-unfetch'
import axios from 'redaxios'
import { JSDOM, CookieJar, VirtualConsole, ResourceLoader } from 'jsdom'
interface JSDOMCookie {
key: string
value: string
domain: string
path: string
hostOnly: boolean
@hmmhmmhm
hmmhmmhm / when.ts
Created June 20, 2021 10:37
await when condition end (typescript)
export const when = (
condition: () => boolean | Promise<boolean>,
timeoutMs = 0,
repeatMs = 500
) => {
return new Promise<void>((resolve) => {
const startTime = Date.now()
const checkFlag = async () => {
if (await condition()) {
resolve()
@hmmhmmhm
hmmhmmhm / gugu.js
Last active February 4, 2022 10:11
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•œ์ค„ ๊ตฌ๊ตฌ๋‹จ
// ์ด ์˜์ƒ ๋ณด๊ณ  ๊ฐ๋ช…๋ฐ›์•„ ๋งŒ๋“ฌ ๐Ÿ˜†ใ…‹ใ…‹ใ…‹ https://youtu.be/UUJKiTcnGK0
[...Array(9)].map((_,a,b)=>b.map((_,b)=>a*b+a+b+1))
@hmmhmmhm
hmmhmmhm / epubOnWeb.ts
Last active August 21, 2024 10:37
EPUB ์›น ๋ธŒ๋ผ์šฐ์ € ํŒŒ์‹ฑ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ & ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ (EPUB Web Browser Parsing Javascript & Typescript)
import JSZip from 'jszip'
// Filter Example: https://gist.github.com/hmmhmmhm/f1383a32b904e85cc7b352ad49a8c8e9
// import { applyFilters } from './filter'
export interface ICollectedFile {
fileName: string
fileExt: string
filePaths: string[]
originName: string
file: JSZip.JSZipObject
@hmmhmmhm
hmmhmmhm / epubFilterExample.ts
Created June 22, 2021 02:09
EPUB ์›น ๋ธŒ๋ผ์šฐ์ € ์ƒ ํ•„ํ„ฐ ์˜ˆ์‹œ
export interface IFilterInput {
container: JSZip
data: ICollectedData
option: IFilterOption
state: IState
}
export interface IFilterOption {
styleType: 'basic' | 'poem'
@hmmhmmhm
hmmhmmhm / useScroll.js
Created June 28, 2021 06:40 — forked from joshuacerbito/useScroll.js
Custom React hook for listening to scroll events
/**
* useScroll React custom hook
* Usage:
* const { scrollX, scrollY, scrollDirection } = useScroll();
*/
import { useState, useEffect } from "react";
export function useScroll() {
const [lastScrollTop, setLastScrollTop] = useState(0);
@hmmhmmhm
hmmhmmhm / random.ts
Created August 30, 2021 09:59
How to create a random number that can be scoped briefly
// ~~(min + Math.random() * max)
// 0 ~ 100
~~(Math.random() * 100)
// 1 ~ 5
~~(1 + Math.random() * 5)
@hmmhmmhm
hmmhmmhm / rand.ts
Created September 13, 2021 08:01
A method of generating random values that are not duplicated...
// if you want better performance, use fpe
// https://gist.github.com/hmmhmmhm/89e200e3501b4d155901baee3cae0f74
const rand = (max) => ~~(Math.random() * max)
const items = []
while(items.length === 100){
const item = rand(100)
if(!items.includes(item))
items.push(item)