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
// not a good solution, loop relies on n, outer variable. | |
// I can include it to loop but then loop needs 4 parameters. | |
def fib(n: Int): Int = { | |
@annotation.tailrec | |
def loop(pp: Int, p: Int, idx: Int): Int = { | |
if (idx == n) | |
pp + p | |
else | |
loop(p, pp + p, idx + 1) | |
} |
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
def tail[A](lst: List[A]): List[A] = lst match { | |
case Nil => Nil | |
case x :: xs => xs | |
} | |
// solution in a book | |
// https://github.com/fpinscala/fpinscala/blob/master/answerkey/datastructures/02.answer.scala | |
/* | |
// Although we could return `Nil` when the input list is empty, we choose to throw an exception instead. This is a somewhat subjective choice. In our experience, taking the tail of an empty list is often a bug, and silently returning a value just means this bug will be discovered later, further from the place where it was introduced. | |
// It's generally good practice when pattern matching to use `_` for any variables you don't intend to use on the right hand side of a pattern. This makes it clear the value isn't relevant. |
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
def gen_redis_proto(*cmd) | |
proto = "" | |
proto << "*"+cmd.length.to_s+"\r\n" | |
cmd.each{|arg| | |
proto << "$"+arg.to_s.bytesize.to_s+"\r\n" | |
proto << arg.to_s+"\r\n" | |
} | |
proto | |
end |
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 threading | |
def repeatEvery(n, func, *args, **kwargs): | |
def and_again(): | |
func(*args, **kwargs) | |
t = threading.Timer(n, and_again) | |
t.daemon = True | |
t.start() | |
t = threading.Timer(n, and_again) | |
t.daemon = True |
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 AssemblyKeys._ | |
name := "elasticsearch-spark-project" | |
version := "1.0-SNAPSHOT" | |
scalaVersion := "2.10.5" | |
libraryDependencies ++= Seq( | |
"org.apache.spark" %% "spark-core" % "1.4.0" % "provided", |
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
015-07-14 17:56:14 TRACE CommonsHttpTransport:186 - Opening HTTP transport to <ip>:9200 | |
2015-07-14 17:56:14 ERROR NetworkClient:130 - Node [Invalid target URI HEAD@null/bfdc.error-2015.07.03/fluentd}] failed (<ip>:9200); selected next node [<ip>:9200] | |
2015-07-14 17:56:14 TRACE NetworkClient:118 - Caught exception while performing request [<ip>:9200][bfdc.error-2015.07.03/fluentd}] - falling back to the next node in line... | |
org.elasticsearch.hadoop.rest.EsHadoopTransportException: Invalid target URI HEAD@null/bfdc.error-2015.07.03/fluentd} | |
at org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport.execute(CommonsHttpTransport.java:393) | |
at org.elasticsearch.hadoop.rest.NetworkClient.execute(NetworkClient.java:101) | |
at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:317) | |
at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:309) | |
at org.elasticsearch.hadoop.rest.RestClient.exists(RestClient.java:366) | |
at org.elasticsearch.hadoop.rest.RestRepository.indexExists(RestReposit |
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
INFO [2015-12-24 13:23:00,008] ({pool-1-thread-87} SchedulerFactory.java[jobStarted]:132) - Job paragraph_1450154939904_730596045 started by scheduler remoteinterpreter_2122769647 | |
INFO [2015-12-24 13:23:00,008] ({pool-1-thread-87} Paragraph.java[jobRun]:191) - run paragraph 20151215-134859_1220614770 using null org.apache.zeppelin.interpreter.LazyOpenInterpreter@89c5e02 | |
ERROR [2015-12-24 13:23:00,009] ({pool-1-thread-87} Job.java[run]:183) - Job failed | |
org.apache.zeppelin.interpreter.InterpreterException: org.apache.thrift.transport.TTransportException: java.net.SocketException: 파이프가 깨어짐 | |
at org.apache.zeppelin.interpreter.remote.RemoteInterpreter.interpret(RemoteInterpreter.java:238) | |
at org.apache.zeppelin.interpreter.LazyOpenInterpreter.interpret(LazyOpenInterpreter.java:93) | |
at org.apache.zeppelin.notebook.Paragraph.jobRun(Paragraph.java:212) | |
at org.apache.zeppelin.scheduler.Job.run(Job.java:170) | |
at org.apache.zeppelin.scheduler.RemoteScheduler$JobRunner.run(RemoteSc |
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
15/12/25 15:22:06 INFO SchedulerFactory: Job remoteInterpretJob_1451024526558 started by scheduler org.apache.zeppelin.spark.SparkInterpreter521673013 | |
15/12/25 15:27:18 WARN HeartbeatReceiver: Removing executor 20150605-162632-2084314122-5050-136170-S1 with no recent heartbeats: 165691 ms exceeds timeout 120000 ms | |
15/12/25 15:27:52 ERROR TaskSchedulerImpl: Lost executor 20150605-162632-2084314122-5050-136170-S1 on <server>: Executor heartbeat timed out after 165691 ms | |
15/12/25 15:28:05 WARN HeartbeatReceiver: Removing executor 20150605-162632-2084314122-5050-136170-S4 with no recent heartbeats: 165691 ms exceeds timeout 120000 ms | |
15/12/25 15:28:06 ERROR TaskSchedulerImpl: Lost executor 20150605-162632-2084314122-5050-136170-S4 on <server>: Executor heartbeat timed out after 165691 ms | |
15/12/25 15:28:06 WARN HeartbeatReceiver: Removing executor 20150605-162632-2084314122-5050-136170-S3 with no recent heartbeats: 165691 ms exceeds timeout 120000 ms | |
15/12/25 15:28:06 ERROR TaskSchedulerImpl: Lost executor 201506 |
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
/** | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
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
/** | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |