Skip to content

Instantly share code, notes, and snippets.

View YannMoisan's full-sized avatar

Yann Moisan YannMoisan

View GitHub Profile
@simonrenger
simonrenger / memoy_managment_cpp_resource_list.md
Last active December 13, 2025 18:56
C++ Memory Management Resource List
@ChristopherDavenport
ChristopherDavenport / predef.sc
Last active September 30, 2021 08:00
Ammonite Shell Baseline
interp.configureCompiler(_.settings.Ydelambdafy.tryToSetColon(List("inline")))
import $plugin.$ivy.`org.typelevel::kind-projector:0.10.3`
import $plugin.$ivy.`com.olegpy::better-monadic-for:0.3.1`
import $ivy.`io.circe::circe-generic:0.13.0-RC1`
import $ivy.`org.http4s::http4s-circe:0.21.0-RC2`
import $ivy.`org.http4s::http4s-dsl:0.21.0-RC2`
import $ivy.`org.http4s::http4s-ember-client:0.21.0-RC2`
import cats._, cats.data._, cats.effect._, cats.implicits._, cats.effect.concurrent._, cats.effect.implicits._, fs2._, org.http4s._, org.http4s.implicits._, scala.concurrent.duration._

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@etorreborre
etorreborre / implicits.scala
Created May 25, 2016 06:35
Show applied implicits in the REPL
scala> import cats.implicits._
import cats.implicits._
scala> (1 -> 2) === (1 -> 3)
res0: Boolean = true
scala> import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._
scala> showCode(reify { (1 -> 2) === (1 -> 3) }.tree)
@odersky
odersky / A simpler way to returning the "current" type in Scala.
Last active April 5, 2024 13:34
A simpler way to returning the "current" type in Scala.
/** This is in reference to @tploecat's blog http://tpolecat.github.io/2015/04/29/f-bounds.html
* where he compares F-bounded polymorphism and type classes for implementing "MyType".
*
* Curiously, the in my mind obvious solution is missing: Use abstract types.
*
* A lot of this material, including an argument against F-bounded for the use-case
* is discussed in:
*
* Kim B. Bruce, Martin Odersky, Philip Wadler:
* A Statically Safe Alternative to Virtual Types. ECOOP 1998: 523-549
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@samklr
samklr / DotProduct.scala
Created August 30, 2013 21:21
DotProduct matrix in scala and on spark
def dotProduct(vector: Array[Int], matrix: Array[Array[Int]]): Array[Int] = {
// ignore dimensionality checks for simplicity of example
(0 to (matrix(0).size - 1)).toArray.map( colIdx => {
val colVec: Array[Int] = matrix.map( rowVec => rowVec(colIdx) )
val elemWiseProd: Array[Int] = (vector zip colVec).map( entryTuple => entryTuple._1 * entryTuple._2 )
elemWiseProd.sum
} )
}
I'm not a fan of G/W/T because:
- in its original form it forces you to use the words "given/when/then" and I prefer to have more freedom when I write specifications (even if the G/W/T pattern is actually followed)
- the implementation makes it hard not to use variables, leading to difficulties in reusing steps and composing behaviors
- I tend to think of a more simple functional, "input-output" way of seeing things when I write specifications
@aloiscochard
aloiscochard / qsbt.sh
Last active March 5, 2018 21:34
QuickSBT - Launch SBT with support for generating /tmp/sbt.quickfix file for Vim
#!/usr/bin/env bash
############
# QuickSBT #
############
# Launch SBT with support for generating /tmp/sbt.quickfix file for Vim
# http://github.com/aloiscochard / https://gist.github.com/4698501
# Error format for SBT, and shortcut to open SBT quickfix file :