Skip to content

Instantly share code, notes, and snippets.

@netzwerg
netzwerg / Print.fr
Last active August 29, 2015 14:26
Behavior of putStr regarding line termination (Haskell vs. Frege vs. Java)
module Print where
-- Identical to the Haskell version (Print.hs)
-- Frege doesn't print line 7 (even a manual stdout.flush afterwards doesn't work)
main = do
putStrLn "A line with line termination"
putStr "A line without line termination, e.g. to prompt for input: "
line <- getLine
putStrLn ("You entered: " ++ line)
@netzwerg
netzwerg / CircleAnimation.elm
Created January 7, 2016 20:18
Circle animation to paste into http://www.elm-lang.org/try
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Time exposing (..)
import Window
import List exposing (..)
import Debug
-- CONFIG
@netzwerg
netzwerg / HoverableYogi.elm
Created January 14, 2016 19:42
Mouse hover example to paste into http://www.elm-lang.org/try
import Graphics.Element exposing (..)
import Signal exposing (..)
import Graphics.Input exposing (hoverable)
main : Signal Element
main =
Signal.map view hover.signal
hover : Signal.Mailbox String
hover = Signal.mailbox "–"
@netzwerg
netzwerg / RectangleOffsets.elm
Last active January 16, 2016 12:49
Demonstrates scanl to paste into http://www.elm-lang.org/try
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element
import Debug exposing (..)
type alias Rect = { width: Float, color: Color }
toForm : (Rect, Float) -> Form
@netzwerg
netzwerg / ZipSpeedTest.java
Created January 22, 2016 18:22
Using RC2, zip variant is 10x slower (1500 ms vs. 150 ms)
import javaslang.collection.List;
import org.junit.Test;
import java.util.Iterator;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class ZipSpeedTest {
private static final java.util.List<String> JAVA_LIST = IntStream.range(0, 1_000_000).mapToObj(String::valueOf).collect(Collectors.toList());
@netzwerg
netzwerg / ZipWithIndexTest.java
Created January 24, 2016 11:23
Using RC3, imperative variant is 2x faster (800 ms vs. 1800 ms), GC going nuts with all the tuples...
import javaslang.collection.Stream;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.junit.Assert.assertEquals;
public class ZipWithIndexTest {
@netzwerg
netzwerg / FizzBuzz.java
Created May 1, 2016 05:06
FizzBuzz in Java 8 with Javaslang
import javaslang.collection.Stream;
/**
* An implementation of https://dierk.gitbooks.io/fregegoodness/content/src/docs/asciidoc/fizzbuzz.html
* using http://www.javaslang.io
*
* @author Rahel Lüthy
*/
public class FizzBuzz {
@netzwerg
netzwerg / config.json
Last active January 13, 2017 09:55
SAAV Customization
{
"title": "Customization Demo",
"allowedValueRange": [1, 10],
"criteria": [
{
"name": "Software Quality",
"aggregatable": true,
"subCriteria": [
{
"name": "Usability",
@netzwerg
netzwerg / .block
Last active March 8, 2017 11:36
D3.js Linear Scale
license: apache-2.0
border: no
@netzwerg
netzwerg / .block
Last active March 8, 2017 11:36
D3.js Bouncing FHNW
license: apache-2.0
border: no