Skip to content

Instantly share code, notes, and snippets.

@clarenced
clarenced / eitherExample.kt
Created October 31, 2020 14:21
Either example with Arrow
class DivisionByZero {
override fun toString(): String {
return "Division by zero"
}
}
fun divide(a: Int, b: Int): Either<DivisionByZero, Int> {
return try {
Right(a / b)

Keybase proof

I hereby claim:

  • I am clarenced on github.
  • I am clarenced (https://keybase.io/clarenced) on keybase.
  • I have a public key whose fingerprint is 51D5 1C15 80A7 0286 F1A5 0D68 EB42 56FA F53D 8555

To claim this, I am signing this object:

String proverbe = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In finibus mollis egestas. Sed in orci sit amet libero pharetra lacinia. " ;
Stream<String> splitAsStream = Pattern.compile(" ").splitAsStream(proverbe);
splitAsStream.forEach(System.out::println);
@clarenced
clarenced / etl
Last active August 29, 2015 14:24
public class Etl {
public Map<String, Integer> transform(Map<Integer, List<String>> old){
Map<Stream<String>, Integer> collect = old.entrySet() //Map.Entry<Integer, List<String>>
.stream() //Stream<Map.Entry<Integer, List<String>>>
.collect(Collectors
.toMap((Map.Entry<Integer, List<String>> entry) -> entry.getValue() //List<String>
.stream() //Stream<List<String>>
$ sbt run
[info] Loading project definition from C:\Users\s814992\workspace-scala\myfirstproject\project
[info] Set current project to parksense (in build file:/C:/Users/s814992/workspace-scala/myfirstproject/)
[info] Updating {file:/C:/Users/s814992/workspace-scala/myfirstproject/}default-39af27...
[info] Resolving org.scala-lang#scala-library;2.9.2 ...
[info] Done updating.
[info] Compiling 1 Scala source to C:\Users\s814992\workspace-scala\myfirstproject\target\scala-2.9.2\classes...
[info] Running com.myfirstproject.Hello
Hello World
[success] Total time: 3 s, completed 2 janv. 2013 14:01:38
package com.myfirstproject
object Hello {
def main(args : Array[String]) = {
println("Hello World")
}
}
name := "myfirstproject" # project name
version := "0.0.0" #project version
scalaVersion := "2.9.2" #the current scala version of the project
$ mkdir myfirstproject
$ cd myfirstproject
$ mkdir -p src/main/java
$ mkdir -p src/main/scala
$ mkdir -p src/main/resources
$ mkdir -p src/test/java
$ mkdir -p src/test/scala
$ mkdir -p src/test/resources
@clarenced
clarenced / .bashrc
Last active December 10, 2015 12:28
SBT_HOME="$HOME/sbt_home"
PATH="$SBT_HOME/sbt":$PATH
$ java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -jar `dirname $0`/sbt-launch.jar "$@"