Skip to content

Instantly share code, notes, and snippets.

View JamesMenetrey's full-sized avatar
🐹
Shifting some bits ...

Jämes Ménétrey JamesMenetrey

🐹
Shifting some bits ...
View GitHub Profile
@JamesMenetrey
JamesMenetrey / a.java
Created July 13, 2018 15:55
Java 10 Cleaner
public class InstanceAroundResource implements AutoCloseable{
//(1)We will delegeta cleaning to Cleaner from Java 9
private static final Cleaner cleaner=Cleaner.create();
//(2)This is definition of internal state, static -> so it has no ref to external instance
//private - to better hide information
private static class EncapsulatedResource implements Runnable{
(...)
}
@JamesMenetrey
JamesMenetrey / README.md
Last active February 4, 2018 23:11
Make Bash on Ubuntu on Windows 10 Look Like the Ubuntu Terminal

Make Bash on Ubuntu on Windows 10 Look Like the Ubuntu Terminal

Install zsh

sudo apt-get install zsh

Install Oh My ZSH

Follow the instructions: https://ohmyz.sh/

@JamesMenetrey
JamesMenetrey / create_cluster.sh
Last active January 9, 2018 19:06 — forked from stat1x/cassandra_cluster.sh
Cassandra cluster
# Remove all running docker container
docker rm -f $(docker ps -a -q)
# Create the cluster
docker run -d -e "CASSANDRA_TOKEN=1" --name cassandra-1 spotify/cassandra:cluster
docker run -d -e "CASSANDRA_TOKEN=10" -e "CASSANDRA_SEEDS=$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-1)" --name cassandra-2 spotify/cassandra:cluster
docker run -d -e "CASSANDRA_TOKEN=100" -e "CASSANDRA_SEEDS=$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-1)" --name cassandra-3 spotify/cassandra:cluster
docker run -d -e "CASSANDRA_TOKEN=1000" -e "CASSANDRA_SEEDS=$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-1)" --name cassandra-4 spotify/cassandra:cluster
docker run -d -e "CASSANDRA_TOKEN=10000" -e "CASSANDRA_SEEDS=$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-1)" --name cassandra-5 spotify/cassandra:cluster
@JamesMenetrey
JamesMenetrey / demo.scala
Last active October 15, 2017 22:05
Phantom types in Scala: leverage type safety over conditional branching
package scalaInAction.chapter8ScalableExtensibleComponents
import org.scalatest.{FlatSpec, Matchers}
class FoodReadyToBeEaten
sealed trait Pizza
object Pizza {
sealed trait EmptyPizza extends Pizza
sealed trait Cheese extends Pizza
@JamesMenetrey
JamesMenetrey / demo.scala
Created October 11, 2017 12:40
Higher-kinded types in Scala
package scalaInAction.chapter8ScalableExtensibleComponents
import org.scalatest.{FlatSpec, Matchers}
trait HasAtLeastOneElement[F[_]] {
def any[A](xs: F[A]): Boolean
}
/**
* Higher-kinded types are types that know how to create a new type from the type argument. That's why
@JamesMenetrey
JamesMenetrey / demo.scala
Last active October 9, 2017 22:42
Structural types in Scala: IDisposable (.NET) rewritten using duck typing.
package scalaInAction.chapter8ScalableExtensibleComponents
import org.scalatest.{FlatSpec, Matchers}
/**
* Declare the .NET keyword as a singleton.
*/
object using {
/**
* Type alias.
@JamesMenetrey
JamesMenetrey / demo.scala
Created October 9, 2017 12:51
Abstract type members in Scala
package scalaInAction.chapter8ScalableExtensibleComponents
import org.scalatest.{FlatSpec, Matchers}
class Food
class Grass extends Food
abstract class Animal {
type SuitableFood <: Food // Upper bound (<:)
@JamesMenetrey
JamesMenetrey / README.md
Last active June 12, 2020 14:39
Generate a valid SSL certificate with public/private key for wildcard domains (compatible with IIS) - 2017

Generate a valid SSL certificate with public/private key for wildcard domains (compatible with IIS) - 2017

Create the configuration file

Open a text editor and paste the following configuration. Save it and name it config.txt.

[req] 
distinguished_name = req_distinguished_name 
x509_extensions = v3_req 
prompt = no 
@JamesMenetrey
JamesMenetrey / README.md
Last active September 29, 2022 08:27
Install Oh-My-Zsh + iTerm2 with Solarized + System-wide console in 2017 (macOS)

Install iTerm2 with Solarized in 2017

Here is the looks and feel of your terminal once the tutorial has been applied on your system:

Install iTerm2

Using Homebrew:

@JamesMenetrey
JamesMenetrey / CollisionManager.java
Created April 14, 2017 16:13
Collision manager for OpenGL in Java
package ch.heigvd.infogr.maths.collision;
import ch.heigvd.infogr.maths.Vector3;
import ch.heigvd.infogr.maths.collision.algorithms.AaBbBoxedCollisionAlgorithm;
import ch.heigvd.infogr.maths.collision.algorithms.ICollisionAlgorithm;
import ch.heigvd.infogr.maths.collision.representation.IBoxedCollidable;
import ch.heigvd.infogr.maths.collision.representation.ICollidable;
import com.jogamp.opengl.GL2;
import javafx.util.Pair;