Skip to content

Instantly share code, notes, and snippets.

View LenKIM's full-sized avatar
🐋
small step make a big difference👣

simplify-len LenKIM

🐋
small step make a big difference👣
View GitHub Profile
@LenKIM
LenKIM / StrategyPatternTest.groovy
Created July 20, 2019 03:27
함수형프로그래밍에서의 전략
package com.nealford.ft.patterns
import org.junit.Test
import static groovy.util.GroovyTestCase.assertEquals
// BEGIN groovy_calc
interface Calc {
def product(n, m)
}
@LenKIM
LenKIM / Customer.groovy
Created July 20, 2019 03:24
함수형프로그래밍에서 템플릿메소드
package templates;
abstract class Customer {
def plan
def Customer() {
plan = []
}
def abstract checkCredit()
@LenKIM
LenKIM / NumberClassifier.java
Created July 19, 2019 15:08
NumberClassifier-JAVA8.ver
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static java.lang.Math.sqrt;
import static java.util.stream.Collectors.toList;
import static java.util.stream.IntStream.range;
public class NumberClassifier {
@LenKIM
LenKIM / 부분적용.scala
Last active July 20, 2019 07:50
부분적용.scala
object 부분적용 {
def price(product: String): Double =
product match {
case "apples" => 140
case "oranges" => 223
}
def withTax(cost: Double, state: String): Double =
state match {
object curringTest extends App {
def filter(xs: List[Int], p: Int => Boolean): List[Int] =
if (xs.isEmpty) xs
else if (p(xs.head)) xs.head :: filter(xs.tail, p)
else filter(xs.tail, p)
def modN(n: Int)(x: Int) = (x % n) == 0
val nums = List(1,2,3,4,5,6,7,8)
println(filter(nums, modN(2)))
// BEGIN imp_classifier
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class ImpNumberClassifierSimple {
private int _number; //<1>
private Map<Integer, Integer> _cache; //<2>
@LenKIM
LenKIM / crwaling.py
Created June 11, 2019 01:12
crawling_test.py
# -*- coding: utf-8 -*-
# !/usr/bin/env python3
import re
from random import choice
import os.path
import requests
from lxml import etree
from bs4 import BeautifulSoup
@LenKIM
LenKIM / file_helpers.py
Last active January 18, 2019 09:13
How to use Callable Object
class Geek:
def __init__(self, bb, cc, dd) -> None:
super().__init__()
self.bb = bb
self.cc = cc
self.dd = dd
self.input = ""
self.print_go(bb, cc, dd)
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.sun.media.jfxmediaimpl.MediaDisposer;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@LenKIM
LenKIM / main_tests.py
Created September 17, 2018 02:58
파싱테스트 관련 자료
#!/usr/bin/python3
# Normal
def test_custom_parser(self):
file_paths = glob.glob("/Users/len/log-analyer-assignment/logdata/20180824/*.txt", recursive=False)
start_time = time.time()
for file_path in file_paths:
with open(str(file_path), 'r', encoding='utf8') as infile:
lines = infile.readlines()
for row_list in tqdm(lines):