Skip to content

Instantly share code, notes, and snippets.

View hanrw's full-sized avatar
🎯
Focusing

itshan hanrw

🎯
Focusing
View GitHub Profile
@hanrw
hanrw / BasicConfigurationTest
Created October 27, 2014 08:06
Solr test demo
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrServerException;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
public class BasicConfigurationTest extends SolrTestCaseJ4 {
@BeforeClass
public static void init() throws Exception {
@hanrw
hanrw / ScalaMocoTest
Created October 27, 2014 08:20
ScalaMocoTest
import com.github.nicholasren.moco.dsl.Conversions._
import com.github.nicholasren.moco.dsl.SMoco
import com.github.nicholasren.moco.dsl.SMoco._
import org.apache.http.client.fluent.Request
import org.scalatest.{BeforeAndAfter, FunSpec}
class ScalaMocoTest extends FunSpec with BeforeAndAfter {
var theServer: SMoco = null
/**
* This file is licensed 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/**
* This file is licensed 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// simple example of the cake pattern
// abstract DAO trait
trait Repository[A, B]{
// saves an entity, returns an ID
def save(entity: A): B
// more features..
}
trait RdbmsRepository extends Repository[MyUserCaseClass, Long]{
@hanrw
hanrw / Account.scala
Last active August 29, 2015 14:10 — forked from amir343/Account.scala
case class Account(name:String, username:String, password:String)

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",
version := "0.1"
scalaVersion := "2.11.7"
val versionOfAkka = "2.3.13"
val versionOfKafka = "0.8.2.0"
libraryDependencies ++= Seq(
"org.apache.kafka" % "kafka-clients" % versionOfKafka exclude("org.slf4j", "slf4j-log4j12") withSources(),
@hanrw
hanrw / FSMDemo.scala
Created December 8, 2015 06:04 — forked from archie/FSMDemo.scala
Demo FSM in Scala and Akka with spec
package demo
import akka.actor.Actor
import akka.actor.FSM
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.ActorRef
sealed trait State
case object Awake extends State