Skip to content

Instantly share code, notes, and snippets.

@beiske
beiske / keybase.md
Created September 1, 2017 08:58
keybase.md

Keybase proof

I hereby claim:

  • I am beiske on github.
  • I am beiske (https://keybase.io/beiske) on keybase.
  • I have a public key whose fingerprint is 83B2 8FD5 4EBF CF81 0FEE FD61 E364 95E0 28B6 36DF

To claim this, I am signing this object:

@beiske
beiske / BadMappingsIndexer.scala
Created September 24, 2014 16:08
BadMappingsDemo
import java.nio.file.Files
import scala.concurrent.duration._
import java.nio.file.Paths
import scala.collection.JavaConverters._
import scala.concurrent.ExecutionContext
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.common.settings.ImmutableSettings
import org.elasticsearch.common.transport.InetSocketTransportAddress
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
@beiske
beiske / BestMatchSearcher.scala
Created July 31, 2014 16:10
Code for getting started with Elasticsearch and Lire
import java.nio.file.Files
import java.nio.file.Paths
import scala.Array.canBuildFrom
import scala.collection.JavaConverters.iterableAsScalaIterableConverter
import scala.concurrent.ExecutionContext.Implicits.global
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.common.settings.ImmutableSettings
import org.elasticsearch.common.transport.InetSocketTransportAddress
analyzer:
nameAnalyzer:
filter:
- lowercase
type: custom
tokenizer: keyword
analyzer:
nameAnalyzer:
filter:
- lowercase
type: custom
tokenizer: keyword
@beiske
beiske / found_thrift_client.py
Last active August 29, 2015 14:01
Connecting to a Found cluster in Python with Thrift and SSL
import os
import json
import base64
from elasticsearch.connection.thrift import *
from elasticsearch import Elasticsearch
from elasticsearch.connection import thrift
from elasticsearch.connection.esthrift import Rest

Create a standard mvn folder structure by putting each file in a folder like this:

├── pom.xml
└── src
    └── test
        ├── java
        │   └── UnknownHostExceptionTest.java
        └── resources
            └── trace.btm
import scala.Option.option2Iterable
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import org.elasticsearch.action.search.SearchResponse
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.common.settings.ImmutableSettings
import org.elasticsearch.common.transport.InetSocketTransportAddress
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
import scala.concurrent.ExecutionContext
import scala.collection.immutable.Stream.consWrapper
import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.duration.Duration
import scala.util.Failure
import scala.util.Success
import org.elasticsearch.action.search.SearchResponse
import org.elasticsearch.client.transport.TransportClient
@beiske
beiske / gist:6793451
Created October 2, 2013 13:08
Attempt at making a streamwrapper that buffers the next result
def prefetch[A](slowSource: Stream[A]): Stream[A] = {
def fetch(stream: => Stream[A]) = {
Future {
stream(1)
}
}
def cons(head: Future[A], tail: => Stream[A]): Stream[A] = {
val next = fetch(tail)
Await.result(head, Duration.Inf) #:: cons(next, tail.tail)
}