Skip to content

Instantly share code, notes, and snippets.

View humanscape-david's full-sized avatar
๐Ÿ™ƒ

David humanscape-david

๐Ÿ™ƒ
View GitHub Profile
@humanscape-david
humanscape-david / rarenote_snu.py
Created September 15, 2021 01:52
์„œ์šธ๋Œ€ํ•™๊ต ํฌ๊ท€์งˆํ™˜์„ผํ„ฐ ๊ด€๋ จ ์งˆํ™˜ ํฌ๋กค๋Ÿฌ
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import pandas as pd
# ์„œ์šธ๋Œ€ํ•™๊ต ํฌ๊ท€์งˆํ™˜์„ผํ„ฐ ์งˆํ™˜ ์ฃผ์†Œ
# ex: ["https://raredisease.snuh.org/[์งˆํ™˜๋ช…]"]
SITE_URL_ARR = []
# To write log format, see https://github.com/kitabisa/teler#configuration
log_format: |
$remote_addr - [$remote_addr] $remote_user - [$time_local]
"$request_method $request_uri $request_protocol" $status $body_bytes_sent
"$http_referer" "$http_user_agent" $request_length $request_time
[$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id
rules:
cache: true
threat:
excludes:
# ์ฝœ๋ฐฑ ๋ฆฌ์Šค๋„ˆ ์ค‘์ฒฉ ์˜ˆ
fun main() {
val result = object : CallBack1 {
override fun callBack(x1: String): CallBack2 {
return object : CallBack2 {
override fun callBack(x2: String): CallBack3 {
return object : CallBack3 {
override fun callBack(x3: String): CallBack4 {
return object : CallBack4 {
override fun callBack(x4: String): CallBack5 {
fun main(args: Array<String>) {
// compose๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์€ ํ•ฉ์„ฑ
val powerOfTwo = { x: Int -> power(x.toDouble(), 2).toInt() }
val gcdPowerOfTwo = { x1: Int, x2: Int -> gcd(powerOfTwo(x1), powerOfTwo(x2)) }
println(gcdPowerOfTwo(25, 5)) // 25 ์ถœ๋ ฅ
// ์ž˜๋ชป๋œ ํ•ฉ์„ฑ
val curriedGcd1 = ::gcd.curried()
val composedGcdPowerOfTwo1 = curriedGcd1 compose powerOfTwo
@humanscape-david
humanscape-david / example.kt
Last active June 30, 2020 05:11
๋งค๊ฐœ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•œ ํ•ฉ์„ฑ ์˜ˆ
val absolute = { i: List<Int> -> i.map { it -> abs(it) } }
val negative = { i: List<Int> -> i.map { it -> -it } }
val minimun = { i: List<Int> -> i.min() }
// compose๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๊ตฌํ˜„
val result1 = minimun(negative(absolute(listOf(3, -1, 5, -2, -4, 8, 14))))
println(result1) // -14 ์ถœ๋ ฅ
// compose๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํƒ€์ž… ์„ ์–ธ ์—†์ด ๊ตฌํ˜„ => ํฌ์ธํŠธ ํ”„๋ฆฌ ์Šคํƒ€์ผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
@humanscape-david
humanscape-david / composed-function.kt
Created June 30, 2020 04:25
์ฝ”ํ‹€๋ฆฐ์—์„œ ํ•ฉ์„ฑํ•จ์ˆ˜์˜ ์ผ๋ฐ˜ํ™”
fun main(args: Array<String>) {
val addThree = { i: Int -> i + 3 }
val twice = { i: Int -> i * 2 }
val composedFunc = addThree compose twice
println(composedFunc(3)) // 9 ์ถœ๋ ฅ
}
infix fun <F, G, R> ((F) -> R).compose(g: (G) -> F): (G) -> R {
return { gInput: G -> this(g(gInput))}
}
@humanscape-david
humanscape-david / compositon-function.kt
Created June 30, 2020 04:18
์ฝ”ํ‹€๋ฆฐ ํ•ฉ์„ฑํ•จ์ˆ˜ ์˜ˆ์‹œ
fun main(args: Array<String>) {
println(composed(3)) // 9 ์ถœ๋ ฅ
}
fun composed(i: Int) = addThree(twice(i))
fun addThree(i: Int) = i + 3
fun twice(i: Int) = i * 2
@humanscape-david
humanscape-david / curried-uncurried.kt
Last active June 30, 2020 04:09
์ฝ”ํ‹€๋ฆฐ์—์„œ ์ปค๋ง ํ•จ์ˆ˜ ์ถ”์ƒํ™”
// curried, uncurried ํ•จ์ˆ˜
fun <P1, P2, P3, R> ((P1, P2, P3) -> R).curried(): (P1) -> (P2) -> (P3) -> R =
{p1: P1 -> {p2: P2 -> {p3:P3 -> this(p1, p2, p3)}}}
fun <P1, P2, P3, R> ((P1) -> (P2) -> (P3) -> R).uncurried(): (P1, P2, P3) -> R =
{p1: P1, p2: P2, p3: P3 -> this(p1)(p2)(p3)}
// curried, uncurried ํ•จ์ˆ˜ ์‚ฌ์šฉ ์˜ˆ์‹œ
fun main(args: Array<String>) {
val multiThree = { a: Int, b: Int, c: Int -> a * b * c }
@humanscape-david
humanscape-david / multiThree.kt
Last active June 30, 2020 03:50
multiThree.kt
fun multiThree(a: Int, b: Int, c: Int): Int = a * b * c
// ์ปค๋ง ํ•จ์ˆ˜
fun multiThree(a: Int) = {b: Int -> {c: Int -> a * b * c } }
fun main(args: Array<String>) {
println(multiThree(1, 2, 3)) // 6 ์ถœ๋ ฅ
val partial1 = multiThree(1)
val partial2 = partial1(2)
@humanscape-david
humanscape-david / app.js
Created June 3, 2020 12:37
์š”์ฒญ header, body ํ™•์ธ
const express = require('express');
const app = express();
app.use(express.json());
app.get('/', function (req, res) {
console.log('headers', req.headers);
console.log('req', req.body);
});
app.listen(3000, function () {