Skip to content

Instantly share code, notes, and snippets.

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

<hmmhmmhm/> hmmhmmhm

๐Ÿงฏ
BURNING!!
View GitHub Profile
@hmmhmmhm
hmmhmmhm / login.ts
Last active July 17, 2020 09:22
NAVER Login for Backend CSR ๋„ค์ด๋ฒ„ ์•„์ด๋”” ๋กœ๊ทธ์ธ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์˜ˆ์ œ ์˜ˆ์‹œ Node.JS ์ด๋ ‡๊ฒŒ ํ•ด๋†“์œผ๋ฉด ๊ตฌ๊ธ€์—์„œ ๊ฒ€์ƒ‰์ด ๋˜๋ ค๋‚˜
let clientId = ''
let clientSecret = ''
let token = ''
let randomId = '' // ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „๋‹ฌ๋  ๊ฐ’
const naverLogin = async () => {
let accessTokenRequestURL = `https://nid.naver.com/oauth2.0/token?client_id=${clientId}&client_secret=${clientSecret}&grant_type=authorization_code&state=${randomId}&code=${token}`
let auctualTokenRequestResponse = await axios.get(
@Brandawg93
Brandawg93 / google_login.ts
Last active May 31, 2025 07:24
Login to Google Account via Puppeteer
import puppeteer from 'puppeteer-extra';
import pluginStealth from 'puppeteer-extra-plugin-stealth'; // Use v2.4.5 instead of latest
import * as readline from 'readline';
puppeteer.use(pluginStealth());
// Use '-h' arg for headful login.
const headless = !process.argv.includes('-h');
// Prompt user for email and password.
@sonbyungjun
sonbyungjun / viewKorean.ts
Created June 2, 2020 02:40
Typescript(Javascript) conversion of amount into Korean Function (ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ(์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ) ๊ธˆ์•ก ํ•œ๊ธ€๋กœ ๋ณ€ํ™˜ ํ•จ์ˆ˜)
export const viewKorean = (num: any): string => {
num = parseInt((num + '').replace(/[^0-9]/g, ''), 10) + '';
if (num == '0') return '์˜';
let number = ['์˜', '์ผ', '์ด', '์‚ผ', '์‚ฌ', '์˜ค', '์œก', '์น ', 'ํŒ”', '๊ตฌ'];
let unit = ['', '๋งŒ', '์–ต', '์กฐ'];
let smallUnit = ['์ฒœ', '๋ฐฑ', '์‹ญ', ''];
let result = [];
let unitCnt = Math.ceil(num.length / 4);
num = num.padStart(unitCnt * 4, '0');
let regexp = /[\w\W]{4}/g;
@nnnnnoel
nnnnnoel / func.js
Created June 2, 2020 02:38
React Native toCommaNumber
export function removeDot(str: string): string {
return str.replace(/(^0)(?=[^.])/, '');
}
export function replComma(str: string): string {
return removeDot(str.replace(/(^[\d,]+\.(?:\d*[^0])?)(0*)$/, '$1').replace(/\.$/, ''));
}
export function addComma(str: string): string {
return str.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
@sonbyungjun
sonbyungjun / search.ts
Created June 2, 2020 02:37
Typescript(Javascript) Array Object Value Search Function (ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ(์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ) ๋ฐฐ์—ด ๊ฐ์ฒด ๊ฐ’ ๊ฒ€์ƒ‰ ํ•จ์ˆ˜)
export function search(nameKey: any, myArray: any, attribute: string){
for (let i=0; i < myArray.length; i++) {
if (myArray[i][attribute] === nameKey) {
return myArray[i];
}
}
}
@nnnnnoel
nnnnnoel / LineChart.js
Created June 2, 2020 02:36
Line Chart Formula
const getLineChartD = ({ data, size, width, padding, topSpacing }) => {
const min = Math.min(...data);
const max = Math.max(...data);
const d = data
.map((v, i) => {
return `${i === 0 ? 'M' : 'L'} ${(i * (width - padding * 5)) / data.length},${
size - (v / (max - min)) * size + (topSpacing || 0)
}`;
}).join(' ');
@sonbyungjun
sonbyungjun / emailSecurity.ts
Created June 2, 2020 02:33
Typescript(Javascript) Email Security Function (ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ(์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ) ์ด๋ฉ”์ผ ๋ธ”๋Ÿฌ์ฒ˜๋ฆฌ ํ•จ์ˆ˜)
export function emailSecurity(userEmail: string){
const id = userEmail.split('@')[0];
const mail = userEmail.split('@')[1];
const maskingId = function(id: string) {
let splitId = id.substring(0,4);
for(let i = 4; i < id.length; i++) {
splitId += '*';
}
return splitId;
};
@sonbyungjun
sonbyungjun / duplicateCheck.ts
Created June 2, 2020 02:32
TypeScript(Javascript) duplicateCheck Function (ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ(์ž๋ฐ”์Šคํฌ๋ฆฝ) ์ค‘๋ณต์ฒดํฌ ํ•จ์ˆ˜)
export function duplicateCheck(array: any[]) {
return array.reduce((t, a) => {
t[a] = (t[a] || 0) + 1;
return t
}, {})
}
@sonbyungjun
sonbyungjun / paginate.ts
Last active June 2, 2020 02:31
TypeScript(Javascript) Paginate Calculation Function (ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ(์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ) ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ณ„์‚ฐ ํ•จ์ˆ˜)
export const paginate = (array: any, index: any, size: any) => {
// transform values
index = Math.abs(parseInt(index));
index = index > 0 ? index - 1 : index;
size = parseInt(size);
size = size < 1 ? 1 : size;
// filter
return [
...array.filter((value: any, n: any) => {
@hmmhmmhm
hmmhmmhm / moment_diff.ts
Last active June 1, 2020 05:17
๋ชจ๋ฉ˜ํŠธ๋ฅผ ํ†ตํ•œ์‹œ๊ฐ„ ๊ฐ’ ๋น„๊ต ์‹œ format ์ ์šฉ๋ฐฉ๋ฒ•
import moment from 'moment'
import 'moment-duration-format'
let currentMoment = moment()
let currentMinuteNum = Number(currentMoment.format('mm'))
let nextMin = 1
let _nextContractTime = moment(currentMoment)
.add(nextMin, 'minute')