This file contains hidden or 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
| /** | |
| * map, flatMap | |
| */ | |
| val l = List(1, 2, 3, 4, 5) | |
| l map (_ * 2) | |
| //option can be considered a sequence that is either empty or has 1 item | |
| def f(x: Int) = if (x > 2) Some(x) else None | |
| l map (f(_)) | |
| l flatMap (f(_)) | |
| def g(v: Int) = List(v - 1, v, v + 1) |
This file contains hidden or 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
| /** ******************* 기초 *********************/ | |
| /** ********************************** | |
| * Partial Application | |
| * | |
| * 인자의 일부만 사용해 호출하기(부분 적용, Partial Application) | |
| * **********************************/ | |
| // 인자의 일부만 사용해 호출하기(부분 적용, Partial Application) | |
| def adder(m: Int, n: Int) = m + n | |
| val add2 = adder(2, _: Int) | |
| add2(3) |
This file contains hidden or 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 -*- | |
| import os, time | |
| from selenium import webdriver | |
| # in order to use unicode | |
| import sys | |
| reload(sys) | |
| sys.setdefaultencoding('utf-8') | |
| # Set up chromedriver path | |
| chromedriver = "/usr/local/bin/chromedriver" |
This file contains hidden or 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 TwitterAnalyzer(val topCount:Int = 20, val fileName:String = "20151003") { | |
| def reduceToTop(urls:org.apache.spark.rdd.RDD[(String, Int)]) { | |
| urls.reduceByKey((a, b) => a + b).map(_.swap).top(topCount).map(_.swap).foreach(println(_)) | |
| } | |
| def analyze() { | |
| val textFile = sc.textFile(fileName + ".tag") | |
| val linesThatHasUrl = textFile.filter(line => line.split("\t")(1) == "add") | |
| val linesThatHasCafeUrl = linesThatHasUrl.map(line => line.split("\t")(23).split(" ")(0)).filter(url => url.startsWith("http://cafe.daum.net")) | |
| val fullUrl = linesThatHasCafeUrl.map(url => (url, 1)) |
This file contains hidden or 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 com.google.common.base.Function; | |
| import com.google.common.collect.Lists; | |
| import com.google.common.primitives.Ints; | |
| import lombok.Data; | |
| import org.junit.Test; | |
| import java.math.BigDecimal; | |
| import java.util.List; | |
| @Data |
This file contains hidden or 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
| buildscript { | |
| ext { | |
| springBootVersion = '1.3.0.RELEASE' | |
| } | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { | |
| classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") | |
| classpath('io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE') |
This file contains hidden or 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 org.junit.Test; | |
| import org.junit.runner.RunWith; | |
| import org.junit.runners.Parameterized; | |
| import org.junit.runners.Parameterized.Parameters; | |
| import java.util.Arrays; | |
| import java.util.Collection; | |
| import static org.hamcrest.CoreMatchers.is; | |
| import static org.junit.Assert.assertThat; |
This file contains hidden or 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
| #!/bin/sh | |
| servers="was1 was2" | |
| for i in $(seq -w 1 11); do | |
| for server in `echo $servers`; do | |
| target_date="201602$i" | |
| echo "count from $server for $target_date" | |
| ssh ssh_id@$server "grep \"Data too long for column 'title' at row 1\] with root cause\" /logdir/logfile.log.$target_date | wc -l" | |
| done | |
| done |
This file contains hidden or 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
| public enum CardDataType { | |
| TYPE_SIMPLE(1, "simple"), | |
| TYPE_IMAGE(2, "image"), | |
| TYPE_LIST(3, "list"); | |
| public int cardType; | |
| private String name; | |
| CardDataType(int cardType, String name) { | |
| this.cardType = cardType; | |
| this.name = name; |
This file contains hidden or 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
| private List<String> getRequestInfo(LoggingEvent event) { | |
| List<String> result = Lists.newArrayList(); | |
| appendIfExists(result, event, IP); | |
| appendIfExists(result, event, ID); | |
| appendIfExists(result, event, DEVICE); | |
| return result; | |
| } | |
| private void appendIfExists(List<String> result, LoggingEvent event, String key) { | |
| String value = (String) event.getValue(key); |