Skip to content

Instantly share code, notes, and snippets.

View HeartSaVioR's full-sized avatar
🏠
Working from home

Jungtaek Lim HeartSaVioR

🏠
Working from home
View GitHub Profile
@HeartSaVioR
HeartSaVioR / ex-2-1.scala
Last active August 29, 2015 14:17
Functional Programming in SCALA (chap 2)
// 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)
}
@HeartSaVioR
HeartSaVioR / ex-3-2.scala
Last active August 29, 2015 14:17
Functional Programming in Scala (chap 3)
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.
@HeartSaVioR
HeartSaVioR / proto.rb
Created June 12, 2015 08:42
proto.rb
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
@HeartSaVioR
HeartSaVioR / experiment-gil-with-cpu-intensive.py
Created July 10, 2015 02:08
Python GIL with CPU intensive
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
@HeartSaVioR
HeartSaVioR / build.sbt
Created July 14, 2015 08:32
build.sbt for Spark 1.4.0 + HBase CDH 5.2.0 + elasticsearch-spark 2.1.0 + and so on
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",
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
@HeartSaVioR
HeartSaVioR / zeppelin-log-scheduler-already-terminated.log
Created December 27, 2015 02:23
Zeppelin error log - Scheduler already terminated
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
@HeartSaVioR
HeartSaVioR / zeppelin-spark-interpreter-core-dumped.log
Created December 28, 2015 01:06
Zeppelin Spark Interpreter Core-dumped
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
@HeartSaVioR
HeartSaVioR / BasicTopology.java
Last active March 26, 2016 07:00
"Speed of light topology Roshan provided" + printing metrics
/**
* 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
@HeartSaVioR
HeartSaVioR / BasicTopology.java
Last active March 26, 2016 07:00
"Speed of light topology Arun provided" + printing metrics
/**
* 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