Skip to content

Instantly share code, notes, and snippets.

View deptno's full-sized avatar
:octocat:
midnight coding

Bonggyun Lee deptno

:octocat:
midnight coding
View GitHub Profile
@deptno
deptno / fetch.ts
Created March 11, 2017 15:21
redux-thunk fetch wrapper
import {parse} from 'url';
import * as qs from 'qs';
const handleError = async response => {
const message = await response.json();
return new Error(JSON.stringify({code: response.status, message}));
};
const prefixer = (action: string) => [`PENDING_${action}`, `OK_${action}`, `ERR_${action}`];
export const GET = (action: string, url: string, query?: Object, hookOk = x => x, hookErr = x => x) => {
@deptno
deptno / .travis.yml
Created March 13, 2017 17:01
travis elastic beanstalk, node, yarn
language: node_js
node_js:
- 'node'
cache:
yarn: true
directories:
- node_modules
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
for f in **/*.js; do git mv "$f" "${f%.js}.ts"; done
@deptno
deptno / rdconfig.json
Last active June 2, 2017 05:33
wrdconfig.json sample
{
"sites": [{
"name": "Top Box Office (US)",
"url": "http://www.imdb.com/chart/boxoffice",
"stages": [{
"type": "list",
"selector": "#boxoffice .titleColumn a",
"attrs": {
"value": "href"
},
@deptno
deptno / definition-lint.js
Created July 8, 2017 08:20
definition pascal, camelcase
const c = require('camelcase');
const p = require('pascalcase');
const src = '' //definition
console.log(
src
.replace(/(\S+):/g, (_, $0) => `${c($0)}:`)
.replace(/interface (\S+)/g, (_, $0) => `interface ${p(c($0))}`)
)
@deptno
deptno / euc_kr_to_utf_8.sh
Created July 22, 2017 09:15
euc-kr to utf-8
for I in ./*.asp ; do iconv -c -f euc-kr -t utf-8 $I > $I.tmp && mv $I.tmp $I ; done
@deptno
deptno / export-path.map.js
Last active August 2, 2018 12:24
next.js@3 static export utility
const root = `${__dirname}/pages`
const path = require('path')
const tree = require('directory-tree')
module.exports.exportPathMap = () => files(tree(root).children)
.reduce((ret, file) => {
ret[file] = {page: file}
return ret
}, {'/': {page: '/index'}})
@deptno
deptno / mongo-db-sync.ts
Last active October 7, 2017 18:35
redux middleware - db sync
import {Middleware} from 'redux'
import {CollectionInsertManyOptions, CollectionInsertOneOptions, MongoClient} from 'mongodb'
export interface Argument {
mongoDbUrl: string
dbCollectionPrefix: string
insertOneOptions?: CollectionInsertOneOptions
insertManyOptions?: CollectionInsertManyOptions
}
console.table(
Array
.from(document.querySelectorAll('.ty04 tr'))
.map(
tr => Array
.from(tr.querySelectorAll('th,td'))
.map(td => td.textContent)
)
)
@deptno
deptno / send-codebuild-result-to-slack.sh
Last active July 13, 2019 11:54
notify codebuild result to slack
echo ${CODEBUILD_BUILD_ID} | awk '{ print "{\"text\": \"빌드로그 <https://ap-northeast-2.console.aws.amazon.com/codebuild/home\?region\=ap-northeast-2\#/builds/" $1 "/view/new|" $1 ">\"}"}' | curl -H "Content-Type: application/json" -X POST -d @- https://api.dev.googit.co/common/send-to-channel-labs