This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import requests | |
import re | |
from bs4 import BeautifulSoup as bs | |
from functools import reduce | |
map = lambda f: lambda xs: [f(x) for x in xs] | |
filter = lambda f: lambda xs: [x for x in xs if f(x)] | |
go = lambda x, *fns: reduce(lambda acc, fn: fn(acc), fns, x) | |
pipe = lambda *fns: lambda x: reduce(lambda acc, fn: fn(acc), fns, x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -* | |
from string import ascii_letters, digits | |
from random import sample | |
letters = ascii_letters + digits | |
url2id_db = {} | |
id2url_db = {} | |
def uid(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -* | |
# 입력 - url 문자열 | |
# 출력 - 숫자와 알파벳으로 이루어진 5자리 문자열 | |
def url2id(url): | |
raise NotImplementedError | |
# 입력 - id 문자열 | |
# 출력 - url 문자열 | |
def id2url(id): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const bodyParser = require('body-parser') | |
const cors = require('cors') | |
const fs = require('mz/fs') | |
const port = process.env.PORT || 3000 | |
const app = express() | |
app.use(bodyParser.json()) | |
app.use(cors()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { promisify } = require('util') | |
const parseString = promisify(require('xml2js').parseString) | |
const rp = require('request-promise') | |
const serviceKey = '서비스키' | |
const url = (stId, busRouteId, ord) => | |
`http://ws.bus.go.kr/api/rest/arrive/getArrInfoByRoute?serviceKey=${serviceKey}&stId=${stId}&busRouteId=${busRouteId}&ord=${ord}` | |
rp(url(119000295, 100100029, 48)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const graph = new Graph() | |
graph.addVertex(1, 2, 3, 4, 5, 6) | |
console.log('Added Verteces') | |
graph.print() // 1 -> | 2 -> | 3 -> | 4 -> | 5 -> | 6 -> | |
graph.addEdge(1, 2) | |
graph.addEdge(1, 5) | |
graph.addEdge(2, 3) | |
graph.addEdge(2, 5) | |
graph.addEdge(3, 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Graph { | |
constructor () { | |
this.vertices = [] // 노드 | |
this.edges = {} // 연결 | |
} | |
get size () { return this.vertices.length } | |
get relations () { | |
return Object.values(this.edges).reduce((acc, edge) => acc + edge.length, 0) / 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('partial-js') | |
const fs = require('mz/fs') | |
const alphabets = 'qwertuiopasdfghjklzxcvbnm' | |
const listVerbs = __(c => `./content/${c}`, fs.readdir) | |
const removeDSStore = _.filter(v => v !== '.DS_Store') | |
const readVerbs = _.map(__(v => `./content/${v[0]}/${v}`, fs.readFile, JSON.parse, c => c.conjugations && c.conjugations.map(cj => (cj.root = c.word, cj)))) | |
const saveJson = category => __(JSON.stringify, _(fs.writeFile, `./${category}.json`, _)) | |
_.filterObject = pred => obj => | |
Object.entries(obj).reduce((acc, [key, val], idx) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('mz/fs') | |
const _ = require('partial-js') | |
const trim = s => s.trim() | |
const verbPath = verb => `content/${verb[0]}/${verb}.json` | |
const getJson = _.pipe(fs.readFile, JSON.parse) | |
const remove2ndPerson = _.reject(c => ![0, 2, 3, 4].includes(c.group_sort) && c.sort == 1 || c.sort == 4) | |
const getConj = _.pipe(trim, verbPath, getJson, v => v.conjugations, remove2ndPerson, _.groupBy('group')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: node_js | |
node_js: | |
- "8" | |
dist: trusty | |
services: | |
- mongodb | |
- redis-server | |
env: | |
- NODE_ENV=ci PORT=3000 | |
cache: |