Skip to content

Instantly share code, notes, and snippets.

View nremond's full-sized avatar

Nicolas Rémond nremond

View GitHub Profile
import scala.collection.mutable
case class Node(
value: Option[Char] = None,
leaves: mutable.ArrayBuffer[String] = mutable.ArrayBuffer.empty,
nodes: mutable.ArrayBuffer[Node] = mutable.ArrayBuffer.empty) {
@nremond
nremond / TestSwitch.java
Created March 31, 2017 12:56
Switch statement with strings
class TestSwitch {
String day;
public TestSwitch(String day) {
this.day = day;
}
class TestSwitch {
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}
Day day;

Keybase proof

I hereby claim:

  • I am nremond on github.
  • I am nremond (https://keybase.io/nremond) on keybase.
  • I have a public key whose fingerprint is F977 A6FE 0378 5224 E90D 48E9 78AB 58AA 3102 58BC

To claim this, I am signing this object:

@nremond
nremond / pem_file_loader
Last active August 29, 2015 14:05
Load a PEM file
import java.net.InetSocketAddress
import java.security.interfaces.RSAPrivateKey
import java.security.cert.X509Certificate
def loadPemFile(pemPath: String): (X509Certificate, RSAPrivateKey) = {
import java.io.ByteArrayInputStream
import java.security.KeyFactory
import java.security.cert.CertificateFactory
import java.security.spec.PKCS8EncodedKeySpec
class NicoBench extends AbstractBenchmark {
val cacheUri = new ConcurrentHashMap[URI, Int]
@Test
@BenchmarkOptions(benchmarkRounds = 20000, warmupRounds = 5000, concurrency = 8)
def uri_hashcode() {
val uri = new URI("http://fake.com/" + ThreadLocalRandom.current.nextInt(0, 1000))
cacheUri.putIfAbsent(uri, 123)
cacheUri.get(uri)
object Nico2 {
import scala.concurrent.duration._
///
implicit class UserNumberImplicit(number: Int) {
def users = new UserNumber(number)
}
class UserNumber(val number: Int)
@nremond
nremond / gist:4699699
Created February 2, 2013 23:20
String interpolation benchmark
import scala.testing.Benchmark
val a="aaa"
val b="bbb"
val c="ccc"
object Format1 extends Benchmark {
def run = String.format("%s - %s - %s\n", a, b, c)
}
@nremond
nremond / gatling-ssl-session-tracking.scala
Last active December 10, 2015 20:08
Gatling simulation that hightlights the problem with Gatling when using SSL session tracking.
package basic
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import bootstrap._
class BasicExampleSimulation extends Simulation {
val counterFeeder = new Feeder[Int] {
private val gen = Stream.from(1).toIterator
@nremond
nremond / gatling_websocket_demo.scala
Last active May 27, 2019 09:28
Demo of Gatling Websocket API
package basic
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import akka.util.duration._
import bootstrap._
import scala.collection.mutable
// Simulation for the Play20 chat sample app
// cf : (https://github.com/playframework/Play20/tree/master/samples/scala/websocket-chat)