Skip to content

Instantly share code, notes, and snippets.

@kakakazuma
kakakazuma / tomcat8
Last active August 29, 2015 14:04
CentOS6.0にTomcat8.0.9をインストールする手順 ref: http://qiita.com/kakakazuma/items/5b390fd7a3c727f41f4a
#!/bin/bash
#
# tomcat8
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat8
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
@kakakazuma
kakakazuma / HTML
Last active August 29, 2015 14:06
「テキストボックスのフォーカス時に選択状態にする」を少しだけクロスブラウザ対応した ref: http://qiita.com/kakakazuma/items/cbf2f523af192e87e059
<input id="test"></input>
@kakakazuma
kakakazuma / es_agg_simple.java
Created September 8, 2015 06:26
elasticsearch aggregation sample by java. simple group by.
/*
ES Aggregation to get result same as result from this SQL
SELECT
fieldA, COUNT(fieldA), SUM(fieldB), AVG(fieldB)
from table
group by fieldA;
*/
//検索クエリの発行
SearchRequestBuilder searchReq = client.prepareSearch("sample_index");
searchReq.setTypes("sample_types");
@kakakazuma
kakakazuma / es_agg_double.java
Created September 8, 2015 06:28
elasticsearch aggregation sample by java. double group by.
/*
ES Aggregation to get result same as result from this SQL
SELECT
fieldA, fieldC, SUM(fieldB)
from table
group by fieldA,fieldC;
*/
SearchRequestBuilder searchReq = client.prepareSearch("sample_index");
searchReq.setTypes("sample_types");
@kakakazuma
kakakazuma / es_agg_datehistogram.java
Created September 8, 2015 06:30
elasticsearch aggregation sample by java. date histogram.
/*
ES Aggregation to get result same as result from this SQL
SELECT
DATE(create_at),fieldA,SUM(fieldB)
from table
group by DATE(create_at),fieldA;
*/
SearchRequestBuilder searchReq = client.prepareSearch("sample_index");
searchReq.setTypes("sample_types");
//例えばInterval.minutes(15)にすると15分ごとの集計ができる
@kakakazuma
kakakazuma / es_agg_where.java
Created September 8, 2015 06:31
elasticsearch aggregation sample by java. where + group by.
/*
SELECT
fieldA, COUNT(fieldA)
from table
WHERE fieldC = "hoge"
AND fieldD = "huga"
AND fieldB > 10
AND fieldB < 100
group by fieldA;
*/
@kakakazuma
kakakazuma / build.sbt
Created November 10, 2015 09:54
build.sbt for Simple Spark Application
name := "SparkSampleApps"
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
("org.apache.spark" % "spark-core_2.10" % "1.3.1" % Provided)
.exclude("org.mortbay.jetty", "servlet-api").
exclude("commons-beanutils", "commons-beanutils-core").
@kakakazuma
kakakazuma / SparkSample1.scala
Created November 10, 2015 10:09
Spark sample application, wordcount from S3
package sample
import org.apache.spark.{SparkConf, SparkContext}
object Sample1 {
val myAccessKey = "xxxxxxx"
val mySecretKey = "yyyyyyy"
val bucket = "your_bucket"
val filepath = "your_path"
@kakakazuma
kakakazuma / ChildParameter.java
Created December 24, 2015 03:44
Validation Constraints with nested objects in play2.0
import play.data.validation.Constraints;
import java.util.List;
public class ChildParameter {
@Constraints.Required
public List<String> idChildList;
@Constraints.Required
@Constraints.Max(2)
@kakakazuma
kakakazuma / Sample.scala
Created May 5, 2016 15:44
play-jsonでnullの含まれるListをパースする ref: http://qiita.com/kakakazuma/items/7cf60811f616d1c40147
case class Sample(id:String, age:Int, params:Seq[Option[String]])
object Sample extends ((String,Int,Seq[Option[String]]) => Sample) {
implicit val SeqOpStringRead = new Reads[Seq[Option[String]]] {
override def reads(json: JsValue): JsResult[Seq[Option[String]]] = {
json match {
case JsArray(seq) => JsSuccess(seq.map(jsvalue => jsvalue.asOpt[String]))
case _ => JsError("Invalid array")
}