Skip to content

Instantly share code, notes, and snippets.

View knutwalker's full-sized avatar
🦀

Paul Horn knutwalker

🦀
View GitHub Profile
@knutwalker
knutwalker / repl.txt
Created April 10, 2014 08:18
so_22953741
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import spray.json._
import spray.json._
scala> import DefaultJsonProtocol._
package org.example;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.LongField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
@knutwalker
knutwalker / keybase.md
Created October 7, 2014 19:30
keybase.md

Keybase proof

I hereby claim:

  • I am knutwalker on github.
  • I am knutwalker (https://keybase.io/knutwalker) on keybase.
  • I have a public key whose fingerprint is CFDD 5271 6B23 352B 4DC0 DFEA AC0C 9439 3B0A AA10

To claim this, I am signing this object:

@knutwalker
knutwalker / Euler-simple.hs
Last active August 29, 2015 14:10
Euler #8 in Haskell
module Main where
import Data.Char
import Data.List
main :: IO ()
main = print
. maximum . map product
. filter((==13) . length) . map (take 13) . tails
. map digitToInt
@knutwalker
knutwalker / SlidingWindow.java
Last active August 29, 2015 14:15
slidingWindow in RxJava
import fj.P;
import fj.P2;
import rx.Observable;
import rx.Subscriber;
public final class SlidingWindow {
public static Observable<P2<Integer, Integer>> viaScan(final Observable<Integer> integers) {
// allocate new Integer outside of integer cache range, so that it can be compared using `==`
// noinspection UnnecessaryBoxing
@knutwalker
knutwalker / TimersTest.java
Last active August 29, 2015 14:15
Usage of Rx TestScheduler
import rx.Observable;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import rx.schedulers.TestScheduler;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
public final class TimersTest {
@knutwalker
knutwalker / J.scala
Created February 17, 2015 16:47
Demo json struff with argonaut and spray
package oanda
import argonaut._, Argonaut._, Shapeless._
import spray.json._, DefaultJsonProtocol._
import scala.util.Try
object J {
sealed trait MyMessages
@knutwalker
knutwalker / Benchmarks.md
Created April 9, 2015 02:51
Benchmarks for RxRedis

Benchmarks

Result for sbt ping-benchmark of rx-redis.

Total time: 00:04:36

Driver Mode Ops/s Error
finagle-redis sync 12,188.275 426.685
finagle-redis async 101,368.142 132,961.138
import shapeless._
import shapeless.labelled._
import shapeless.ops.record._
import scala.annotation.implicitNotFound
@implicitNotFound("Cannot prove that ${A} has an 'id: Int' field.")
trait HasId[A] {
def apply(a: A): Int
}
@knutwalker
knutwalker / Main.scala
Created August 25, 2015 12:31
Demonstrates various possibilities to declare a val and the resulting bytecode
/**
* Demonstrates various possibilities to declare a val and the resulting bytecode.
*
* Main takeaways are:
* - `private[this]` does not generate a getter and genertes direct field access
* - compile time constants are `final val x = e` with an optional modifier (§4.1)
* - final must be given, even if enclosing class is already final (§ 5.2 - 'final')
* - no type annotation may be present
*/
final class Main {