This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sumNonTail(ints: List[Int]): Int = { | |
ints match { | |
case Nil => 0 | |
case x :: xs => x + sumNonTail(xs) | |
} | |
// bytecode | |
// temp = sumNonTail(i) <-- recursive call not in tail position, the result of the recursive call is being 'post-processed' and has to be stored on the stack as it cant return out | |
// return x + temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val testSource = Source(1 until 50) | |
val processingFlow: Flow[Int, Int, NotUsed] = Flow[Int].mapAsyncUnordered(10)(x => Future { | |
println(s"Kicking off $x") | |
Thread.sleep(Random.nextInt(500)) | |
x * 10 | |
}) | |
testSource.via(processingFlow).runWith(Sink.seq[Int])``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#this script should pull all root CAs from the mac os keychain and add them to the jre's keystore | |
#Comes with absolutely no warranty and all the usual disclaimers | |
mkdir temp-extract | |
cd temp-extract | |
keystore=$JAVA_HOME/jre/lib/security/cacerts | |
echo "making backup of keystore $keystore to ~/keystore.backup" | |
set -e -o pipefail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #!Swift-. | |
import Foundation | |
// MARK: - () classes | |
// Solution 1: | |
// - Use classes instead of struct | |
// Issue: Violate the concept of moving model to the value layer | |
// http://realm.io/news/andy-matuschak-controlling-complexity/ |