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
// notice that we first take 2 arguments and then a single argument | |
def betterWayToCurry(a: Int, b: String)(c: Double) = { | |
println("a: " + a + ", b: " + b + ", c: " + c) | |
} | |
val f2 = betterWayToCurry(1, "str") _ // first 2 params saved | |
f2(3.14) // now we can call using the third |
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 someFunc(a: Int, b: String, c: Double) = { | |
println("a: " + a + ", b: " + b + ", c: " + c) | |
} | |
someFunc(1, "str", 3.14) // we need all parameters to call it | |
// we're turning 3-arg function into 1-arg function | |
def someFuncCurried(a: Int, b: String) = { | |
def temp(c: Double) = { | |
someFunc(a, b, c) // a and b are remembered, only c is needed |
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
import numpy as np | |
M1 = np.array([[1, 2], [3, 4], [5, 6]]) # matrix M1 | |
M2 = np.array([[7], [8], [9]]) # matrix M2 | |
M3 = np.c_[M1, M2] # combine | |
M4 = M3.T # transpose of M3 |
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 createSomeSortOfComplicatedString(someImportantVariable: String, otherImportantThing: String) = { | |
val a = someImportantVariable | |
val b = otherImportantThing | |
s"""<a href="#" target="_blank" onclick="$a(); $b()">somestring</a>""" | |
} |
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
class DBClient { | |
// ... | |
def createDBConnection(dbUsername: String, dbPassword: String, dbPort: Int, dbName: String) = { | |
// we're in a db context, are all those prefixes necessary? | |
} | |
def createConnection(user: String, pass: String, port: Int, db: String) = { | |
// more concise |
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 example1(trainInstances: Array[Array[Double]], trainLabels: Array[Double]) = { | |
// trainInstances and trainLabels are OK, but we could do better | |
} | |
def example2(xTrain: Array[Array[Double]], yTrain: Array[Double]) = { | |
// X is a common convention for instance list, x usually represents a single instance | |
// but just to stick to the camel case convention, we could not use X | |
// it's misleading | |
} |
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
// long variables names are somewhat hiding the underlying equation. | |
// long method name is ok though. | |
def calculateSomethingImportant1(someImportantVariable: Int, someOtherImportantVarible: Double) = { | |
math.pow(someImportantVariable, 2) * someOtherImportantVarible + math.pow(someOtherImportantVarible, 2) + someImportantVariable | |
} | |
// it's more clear that the equation is x^2 y + y^2 x | |
def calculateSomethingImportant2(x: Int, y: Double) = { | |
math.pow(x, 2) * y + math.pow(y, 2) + x | |
} |
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
#!/usr/bin/env bash | |
if [ "$#" -ne 4 ]; then | |
echo "usage: $0 <normal-label> <anomaly-label> <K-percent> <actual__predicted__confidence.csv>" | |
exit 1 | |
fi | |
LABEL_0=$1 | |
LABEL_1=$2 | |
K=$3 # percent |
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
> export OMP_NUM_THREADS=6 | |
> export OMP_PROC_BIND="CLOSE" | |
> export GOMP_CPU_AFFINITY="0 1 2 3 4 5" | |
> ./runtests --gtest_filter="PlaygroundTests.FastScalar" | |
Note: Google Test filter = PlaygroundTests.FastScalar | |
[==========] Running 1 test from 1 test case. | |
[----------] Global test environment set-up. | |
[----------] 1 test from PlaygroundTests | |
[ RUN ] PlaygroundTests.FastScalar |
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
> export OMP_NUM_THREADS=6 | |
> ./runtests --gtest_filter="PlaygroundTests.FastScalar" | |
Note: Google Test filter = PlaygroundTests.FastScalar | |
[==========] Running 1 test from 1 test case. | |
[----------] Global test environment set-up. | |
[----------] 1 test from PlaygroundTests | |
[ RUN ] PlaygroundTests.FastScalar | |