Skip to content

Instantly share code, notes, and snippets.

View lucamolteni's full-sized avatar
🏠
Working from home

Luca Molteni lucamolteni

🏠
Working from home
View GitHub Profile
public static void main(String[] args) {
final int parallelism = 8;
final ExecutorService executor = Executors.newFixedThreadPool(parallelism);
final CyclicBarrier started = new CyclicBarrier(parallelism);
final Callable<Long> task = () -> {
started.await();
final Thread current = Thread.currentThread();
long executions = 0;
while (!current.isInterrupted()) {
//quello che deve fare sul DM
@npearce
npearce / install-docker.md
Last active July 22, 2024 18:07
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
abstract class Animal<F extends Food> { abstract void eats(F f);}
abstract class Food {}
class Veg extends Food {}
class Meat extends Food {}
class Grass extends Veg {}
class Carrot extends Veg {}
class Cow extends Animal<Veg> { void eats(Veg f) {}}
class Main {
public static void main(String[] args) {
@lucamolteni
lucamolteni / dump GDST to DRL.java
Created February 5, 2018 10:46 — forked from tarilabs/dump GDST to DRL.java
dump GDST to DRL
org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 unmarshal =
org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence.getInstance().unmarshal(
new String(Files.readAllBytes(Paths.get("src/main/resources/guidedTable.gdst")))
);
String drl = org.drools.workbench.models.guided.dtable.backend.GuidedDTDRLPersistence.getInstance().marshal(unmarshal);
System.out.println(drl);

Trashing the Vodafone Station

How to replace the Vodafone Station with your very own router

Vodafone forces its customers to use their modem/router, the "Vodafone Station": using any other router is impossible because authentication is being done via a custom PPPoE setup.
In the PPPoE packet there is a field named Host-Uniq which is used to separate packets from different PPPoE sessions: Vodafone requires the Station serial number to be put in this field as authentication.

Hardware setup

A Linux router with root access is needed to replace the Station with. With an xDSL connection a modem with a custom firmware like OpenWrt has to be used, most likely one based on a Lantiq SoC.
For a FTTH internet connection then every machine with at least two gigabit ethernet interface and a decent CPU will do it.

@tarilabs
tarilabs / dump GDST to DRL.java
Created January 13, 2017 21:53
dump GDST to DRL
org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 unmarshal =
org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence.getInstance().unmarshal(
new String(Files.readAllBytes(Paths.get("src/main/resources/guidedTable.gdst")))
);
String drl = org.drools.workbench.models.guided.dtable.backend.GuidedDTDRLPersistence.getInstance().marshal(unmarshal);
System.out.println(drl);
@chrisdone
chrisdone / expression_problem.hs
Created November 2, 2016 11:34 — forked from elnygren/expression_problem.clj
Solving the Expression Problem with Haskell
{-# LANGUAGE NamedFieldPuns #-}
-- The Expression Problem and my sources:
-- http://stackoverflow.com/questions/3596366/what-is-the-expression-problem
-- http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/
-- http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/
-- http://www.ibm.com/developerworks/library/j-clojure-protocols/
-- To begin demonstrating the problem, we first need some
@raichoo
raichoo / summer.hs
Created September 30, 2016 16:53
Haskell Example
module Assign where
import Data.IORef
mkSummer :: IO (Int -> Int -> IO Int)
mkSummer = do
ref <- newIORef 0
return $ \x y -> do
val <- readIORef ref
@snoyberg
snoyberg / upper-bounds.md
Created May 27, 2016 03:13
Michael Snoyman's personal take on PVP version upper bounds

In response to a request on Reddit, I'm writing up my thoughts on PVP upper bounds. I'm putting this in a Gist since I don't want to start yet another debate on the matter, just provide some information to someone who asked for it. Please don't turn this into a flame war :)

For those unaware: the Package Versioning Policy is a set of recommendations covering how to give version numbers to your packages, and how to set upper and lower bounds on your dependencies.

I'll start by saying: I support completely with the PVP's recommendations on how to assign version numbers. While there are plenty of points in this design space, the PVP is an unobjectionable one, and consistency in the community is good. On multiple occasions, I have reached out to package authors to encourage compliance with this. (However, I've always done so privately, as opposed to a statement on Reddit, as I believe that to be a more likely route to successful convincing.)

The issue aro