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 / 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 / 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 / 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"
},
for f in **/*.js; do git mv "$f" "${f%.js}.ts"; done
@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
@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 / cipher.js
Created December 29, 2016 12:13
[cli] encrypt, decrypt via aes-256-ctr
#!/usr/bin/env node
const crypto = require('crypto');
const alg = 'aes-256-ctr';
const usage = _ => {
console.log('[usage]');
['c', 'd'].map(opt => console.log(` ${exe} -${opt} secret payload`));
process.exit();
};
const [_, exe, opt = '-h', secret, payload] = process.argv;
@deptno
deptno / fetch_4clojure.js
Last active January 1, 2017 00:39
fetch 4clojure problem
const FormData = require('form-data');
const fetch = require('node-fetch');
const cheerio = require('cheerio');
const problem = problem => new Promise(async (resolve, reject) => {
try {
const result = await fetch(`http://www.4clojure.com/problem/${problem}`);
const html = await result.text();
const $ = cheerio.load(html);
const number = $('#prob-number').text();
@deptno
deptno / stop-ecs-first-container
Created August 30, 2016 18:44
ecs cluster stop first container
aws ecs stop-task --cluster FoxCrane --region ap-northeast-1 --task `aws ecs list-tasks --cluster FoxCrane --region ap-northeast-1 | grep arn | node -e "i = process.stdin; i.resume(); i.on('data', data => console.log(data.toString().trim().replace(/\"/g, '')));"`
docker build -t deptno/capturer . && docker tag deptno/capturer:latest 874372296913.dkr.ecr.ap-northeast-1.amazonaws.com/deptno/capturer:latest && docker push 874372296913.dkr.ecr.ap-northeast-1.amazonaws.com/deptno/capturer:latest