Skip to content

Instantly share code, notes, and snippets.

View uyu423's full-sized avatar

Yongwoo Yu (Yowu) uyu423

View GitHub Profile
@uyu423
uyu423 / CatchApiServerExceptionWithTelegramBot.js
Last active March 20, 2020 16:48
서버에서 나는 Exception을 텔레그램 봇으로 알림을 받아보자
import express from 'express';
import fetch from 'node-fetch';
const app = express();
app.get('/error/:number', (request, response) => {
try {
const result = occurError(request.params.number);
response.json(result);
} catch (error) {
import ioredis from 'ioredis';
import { DateTime } from 'luxon';
interface IRedisOption {
expire: number | false;
}
type IRedisResponse<T> = IRedisHaveDataSuccessResponse<T> | IRedisNotHaveDataSuccessResponse | IRedisFailureResponse;
interface IRedisCommonResponse {
@uyu423
uyu423 / asyncFunctionSeriesDoUsingArrayReduce.ts
Created December 17, 2019 05:15
async function series do using array reduce
const array = [];
array.reduce((promise, payload) => {
return promise.then(() => {
// something await function do
});
}, Promise.resolve());
/*
* Simplic Linked List Structure
* by Yowu (uyu423@gmail.com || http://luckyyowu.tistory.com)
* Date : 2016. 04. 15
* Development Env.
* Ubuntu 15.10 (x64, Linux Kernel 4.2.0)
* GNU Compiler Collection 5.2.1
* Vi IMproved 7.4, File Encoding UTF-8
*/
#include <stdio.h>
@uyu423
uyu423 / webpack.config.js
Created March 6, 2017 03:10
simple and default webpack config js (2017.03.06, webpack 2.2.1)
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'public/'),
filename: 'bundle.js',
},
<head>
<title>JSON Basic</title>
<meta charset="utf-8"/>
</head>
<body>
<script>
/* JSON Definition */
var json = '{ "NAME" : "Yongwoo", "AGE" : 25, "UNIVERSITY" : "Catholic Univ, of Korea", "MAJOR" : "Computer Science" }';
/* JSON Parse and Check */
@uyu423
uyu423 / myNodejsRepositoryPattern.js
Last active April 21, 2018 16:28
Node.js 에서 사용할 수 있는 효율적인 Repository Pattern 에 대해 생각해보자
import config from 'getconfig';
import knex from 'knex';
import mongoose from 'mongoose';
import { User, Log } from './domainObjects';
import { Log as LogSchema } from './mongodbSchemas';
class MySQL {
constructor() {
this.driver = knex(config.DATABASE.MYSQL);
}
@uyu423
uyu423 / NodejsSingletonPattern.js
Created January 3, 2018 20:17
Common Node.js Singleton pattern
// Singleton.js
class Singleton {
constructor(initValue = 0) {
this.value = initValue;
}
setValue(value) {
this.value += value;
}
getValue() {
return this.value;
const knex = require('knex')({
client: 'mysql',
connection: {
host: 'hostname',
user: 'usernmae',
password: 'password',
database: 'dbname',
},
});
const fetch = require('node-fetch');
class Money {
constructor(value) {
if (value < 0) throw Error('Money Type Valiation Exception');
this.value = value;
}
}
class Email {
constructor(email) {
const regExp = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;