Skip to content

Instantly share code, notes, and snippets.

View ygrenzinger's full-sized avatar

Yannick Grenzinger ygrenzinger

View GitHub Profile
@ygrenzinger
ygrenzinger / GregorianToJodaTimeConverter
Created April 30, 2014 15:01
Selma Mapping question
package com.sfr.checkout.util;
import org.joda.time.DateTime;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* Created by ygrenzinger on 30/04/2014.
*/
public class GregorianToJodaTimeConverter {
@ygrenzinger
ygrenzinger / Concurrent.java
Created December 24, 2014 17:42
Poor Man's Concurrency Monad
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
public class Concurrent<A> {
private final Function<Function<A, Action>, Action> func;
@ygrenzinger
ygrenzinger / lab6
Created December 27, 2014 08:44
ROSE TREES, FUNCTORS, MONOIDS, FOLDABLES
------------------------------------------------------------------------------------------------------------------------------
-- ROSE TREES, FUNCTORS, MONOIDS, FOLDABLES
------------------------------------------------------------------------------------------------------------------------------
data Rose a = a :> [Rose a] deriving Show
-- ===================================
-- Ex. 0-2
-- ===================================
@ygrenzinger
ygrenzinger / gist:7c7db1853525b0b30bb0
Created June 12, 2015 21:37
ZonedDateTime and Cassandra : frozen ?
package com.mycompany.myapp.domain;
import java.time.ZonedDateTime;
import java.util.Date;
import com.datastax.driver.mapping.annotations.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.validator.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec J-D D-N Winter Spring Summer Autumn
1880 -29 -19 -17 -27 -13 -28 -22 -6 -16 -15 -18 -20 -19 *** **** -19 -19 -16
1881 -8 -13 2 -2 -3 -27 -5 -1 -8 -18 -25 -14 -10 -11 -13 -1 -11 -17
1882 10 10 2 -19 -17 -24 -9 5 0 -21 -20 -24 -9 -8 2 -11 -9 -14
1883 -32 -41 -17 -23 -24 -11 -7 -12 -18 -11 -19 -17 -19 -20 -32 -22 -10 -16
1884 -17 -11 -33 -35 -31 -37 -33 -25 -22 -22 -30 -28 -27 -26 -15 -33 -32 -25
1885 -64 -29 -23 -44 -41 -50 -28 -27 -19 -19 -22 -5 -31 -33 -41 -36 -35 -20
1886 -41 -45 -41 -28 -27 -39 -15 -31 -18 -25 -26 -24 -30 -28 -30 -32 -28 -23
1887 -65 -47 -31 -37 -33 -20 -18 -27 -19 -32 -25 -37 -33 -32 -46 -33 -21 -26
1888 -42 -42 -47 -28 -21 -20 -8 -10 -7 2 0 -11 -20 -22 -40 -32 -13 -2
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec J-D D-N Winter Spring Summer Autumn
1880 -29 -19 -17 -27 -13 -28 -22 -6 -16 -15 -18 -20 -19 *** **** -19 -19 -16
1881 -8 -13 2 -2 -3 -27 -5 -1 -8 -18 -25 -14 -10 -11 -13 -1 -11 -17
1882 10 10 2 -19 -17 -24 -9 5 0 -21 -20 -24 -9 -8 2 -11 -9 -14
1883 -32 -41 -17 -23 -24 -11 -7 -12 -18 -11 -19 -17 -19 -20 -32 -22 -10 -16
1884 -17 -11 -33 -35 -31 -37 -33 -25 -22 -22 -30 -28 -27 -26 -15 -33 -32 -25
1885 -64 -29 -23 -44 -41 -50 -28 -27 -19 -19 -22 -5 -31 -33 -41 -36 -35 -20
1886 -41 -45 -41 -28 -27 -39 -15 -31 -18 -25 -26 -24 -30 -28 -30 -32 -28 -23
1887 -65 -47 -31 -37 -33 -20 -18 -27 -19 -32 -25 -37 -33 -32 -46 -33 -21 -26
1888 -42 -42 -47 -28 -21 -20 -8 -10 -7 2 0 -11 -20 -22 -40 -32 -13 -2

Hello,

I have done a lot of hard work to have an acceptable dataviz. D3.js is powerfull but really difficult to tweak when you want a perfect design. Hope you will find it interesting.

I wanted to use a Treemap because I love this dataviz but I should first found a good data for this. The budget data is perfect for this and Treemap is a great layout to have a quick and clear understanding where the budget is spend.

I have finally used the Paris (France) annual budget available here: http://opendata.paris.fr/explore/dataset/budget-votes-ap-autotrisations-de-programmes/?tab=metas

I had first to filter the data to keep only the expenditure then convert the CSV format to a nested JSON using the following code:

@ygrenzinger
ygrenzinger / fsharp-module-2.fs
Created December 6, 2015 18:59
Solution for question 3 Koan of Edx F# Module 2
open System
let readIntValue () : int =
let canparse, keyin = Int32.TryParse(Console.ReadLine())
if canparse then keyin
else 0
let readPerson (index : int) : (string * int) =
Console.WriteLine("info of person number {0}", index)
Console.WriteLine("Enter name: ")
open System
type Person = {
Name : string
Age : int
}
let deal (person: Person) =
match person with
| { Person.Name = name; Person.Age = age } when age >= 20 -> printfn "%s is adult." name
@ygrenzinger
ygrenzinger / fsharp-module-3.fs
Created December 7, 2015 21:30
Solution for question of Edx F# Module 3
open System
let goldenratio = (1.0 + Math.Sqrt(5.0)) / 2.0
let calculateRatio x = x * goldenratio
let rec inputValue () : int =
Console.WriteLine("Please input value")
let couldParse, i = Int32.TryParse(Console.ReadLine())
if couldParse then i
else inputValue()