Skip to content

Instantly share code, notes, and snippets.

Dierk König Dierk

View GitHub Profile
Dierk / MultipleButtonsDemo.groovy
Created Jan 1, 2017
GroovyFX: factory methods for a composite view
View MultipleButtonsDemo.groovy
import static groovyx.javafx.GroovyFX.start
Demo of using methods to create multiple nodes (here Buttons) as a composite view and use those
factory methods multiple times.
@author Dierk Koenig
start {
sgb = delegate
Dierk /
Created Dec 8, 2016
AntHill simulation using Frege STM
module Ants where
import STM
import Control.Concurrent (forkIO, forkOS)
import Data.List (!!, nub, sortBy)
import System.Random
Dierk / Counter.tsx
Last active Dec 3, 2016
A graphical multiplication table in Typescript/React. See live at
View Counter.tsx
import * as React from "react";
export interface HelloProps { compiler: string; framework: string; }
export interface HelloState { slices: number; table: number }
export class Hello extends React.Component<HelloProps, HelloState> {
constructor(props: HelloProps) {
this.state = { slices:10, table:2 }
Dierk / Counter.elm
Last active Dec 1, 2016
A graphical multiplication table written in elm (see Counter.purs for the same in purescript). Live:
View Counter.elm
import Html exposing (Html, button, div, text)
import Html.App as App
import Html.Events exposing (onClick)
import Svg exposing (svg, circle, line)
import Svg.Attributes exposing (..)
import List exposing (map, (::))
main =
App.beginnerProgram { model = state, view = view, update = update }
Dierk / Counter.purs
Last active Nov 26, 2016
A graphical multiplication table written in PureScript/Pux, try at
View Counter.purs
module App.Counter where
import Prelude (($), (+), (-), (*), (/), (>), const, show)
import Data.Array ((..), (:), mapWithIndex)
import Data.Int (toNumber, floor)
import Math (sin, cos, pi )
import Pux.Html (Html, div, span, button, text, canvas, svg, circle, line )
import Pux.Html.Attributes (width, height, viewBox, cx, cy, r, fill, x1, y1, x2, y2, stroke, strokeWidth)
import Pux.Html.Events (onClick)
Dierk / Main.purs
Created Nov 14, 2016
Monoidal Fizzbuzz in Purescript
View Main.purs
module Main where
import Control.Monad.Eff.Console (log)
import Data.List.Lazy (take, zipWith, fromFoldable, cycle, iterate, foldr)
import Data.Monoid (mempty, (<>))
import Data.Maybe (Maybe(..), fromMaybe)
import Prelude ( show, map, ($), (+))
main = do
View Iterate.groovy
// Haskell-style iterate function in Groovy
Closure iterate(def value, Closure nextValue) {
return { value = nextValue value }
// use for iteration
def iter = iterate(0) { it + 1}
Dierk /
Last active Mar 22, 2016
adding numbers one to ten can easily lead to random results when done in parallel
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
public class RNG {
static Supplier<Integer> countGen(AtomicInteger i) {
return (()-> i.getAndIncrement());
Dierk /
Created Feb 4, 2016
A silly clock using Frege STM
module SillyClock where
import STM
import Control.Concurrent
type Counter = TVar Int
newCounter :: STM Counter
newCounter = 0
Dierk /
Created Aug 17, 2015
an impure parallel stream that should only map but actually serves as random number generator
import java.util.*;
import java.util.function.*;
public class ParallelStreamTest {
static class IntGenerator implements Supplier<Integer> {
private int current = 0;
You can’t perform that action at this time.