Skip to content

Instantly share code, notes, and snippets.

@stumash
stumash / VirtualenvQuickGuide.md
Last active September 21, 2018 17:22
python virtualenv as fast as possible

Create a virtualenv

make a virtualenv in a directory called vdir with:

$ virtualenv vdir [-p pythonX.X]

Activate a virtualenv

start using the virtualenv in vdir with:

$ source vdir/bin/activate

@stumash
stumash / co_and_contra_variance.scala
Last active April 8, 2020 05:16
scala covariance and contravariance
import scala.collection.mutable.ArrayDeque
object Co_and_Contra_Variance {
def main(args: Array[String]): Unit = {
theBasicIdea() // - What covariance and contravariance let you do, without discussing why or how
theCoreConceptIsBasedOnFunctions() // - How do we decide if function f1 can be substituted by f2? (aka f2 is subtype of f1)
bringItAllTogether() // - Now that we know why and how, let's see how it applies
}
def theBasicIdea(): Unit = {
@stumash
stumash / byname.scala
Last active February 3, 2021 09:16
by-name function calls in scala
object ByName {
/**
* So-called 'by name' function parameters are basically automatically wrapped in thunks
*
* how 'by name' function are desugared:
*
* def f(x: => Int): Int = { x; x }
* f( { println("once"); 1 } )
*
* desugars to