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
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);
@lucamolteni
lucamolteni / summer.hs
Created October 7, 2016 09:12 — forked from raichoo/summer.hs
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
@lucamolteni
lucamolteni / shapeless-session.txt
Created May 2, 2016 14:02 — forked from milessabin/shapeless-session.txt
shapeless on the Ammonite REPL with no dependencies other than an installed JDK. Many thanks to @przemekpokrywka for the idea, @alxarchambault for Coursier and @li_haoyi for Ammonite.
miles@frege:~$ ./shapeless.sh
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_51)
@ val l = 23 :: "foo" :: true :: HNil
l: Int :: String :: Boolean :: HNil = ::(23, ::("foo", ::(true, HNil)))
@