Skip to content

Instantly share code, notes, and snippets.

View mtorchiano's full-sized avatar

Marco Torchiano mtorchiano

View GitHub Profile
@mtorchiano
mtorchiano / YodaPieChart.R
Created February 10, 2016 17:02
Yoda Pie Chart
d=c("Do"=.5,"Do not"=.5,"Try"=0)
par(mar=c(0,0,1,5))
pie(d,col=0:2,main="Your options according to Yoda")
legend(1,1,legend=names(d),fill=0:2,bty="n",xpd=T)
@mtorchiano
mtorchiano / .block
Last active February 16, 2016 15:57
Yoda Pie Chart D3js
license: gpl-3.0
@mtorchiano
mtorchiano / ScaricaMarcatori
Last active March 14, 2016 07:51
Classifica Marcatori Serie A
## Python 3 script per scaricare la classifica dei marcatori
##
import urllib.request
from bs4 import BeautifulSoup
print("Downloading page...")
page=urllib.request.urlopen("http://sport.repubblica.it/marcatori/A").read()
print("Parsing and extracting data...")
soup = BeautifulSoup(page,"html.parser")
@mtorchiano
mtorchiano / Incremental Transformation of an Iterable Sequence in Java.md
Last active April 3, 2017 09:28
Incremental Transformation of an Iterable Sequence in Java
@mtorchiano
mtorchiano / SortingEvolution.java
Created April 20, 2016 15:58
Sorting evolution
import java.util.Arrays;
import java.util.Comparator;
import static java.util.Comparator.*;
/**
* How sorting an array of strings by descending length
* evolved with the introduction of new Java technologies.
*/
public class SortingEvolution {
public static void main(String[] args) {
@mtorchiano
mtorchiano / README.md
Last active May 30, 2016 19:08
Where we donate vs. Diseases that kill us

Where we donate vs. Diseases that kill us - Paired Barchart

This gist reports a redesign of the graph shown in the August 20, 2014 article by Vox.

The original diagram uses two paired bubble charts with categorical levels encoded in colors.

The re-design presented here makes use of two paired opposed bar charts.

@mtorchiano
mtorchiano / README.md
Last active May 30, 2016 19:10
Where we donate vs. Diseases that kill us

Where we donate vs. Diseases that kill us - Slopegraph

This gist reports a redesign of the graph shown in the August 20, 2014 article by Vox.

The original diagram uses two paired bubble charts with categorical levels encoded in colors.

The re-design presented here makes use of a slopegraph.

@mtorchiano
mtorchiano / Java idioms for exposing properties.md
Last active April 3, 2017 09:28
Java idioms for exposing properties

Java idioms for exposing properties

Creative Commons License
This work by Marco Torchiano is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


In several application where a general purpose container needs to access specific objects, properties represent a common technique.

We can loosely define a property as an attribute of an object that can be accessed programmatically based on run-time only information.

@mtorchiano
mtorchiano / _README.md
Created April 23, 2018 11:33
Replacing Observer-Observable (inheritance vs. composition)

Replacing Observer-Observable (inheritance vs. composition)

Since Java 9 the pair Observer-Observable have been declared deprecated.

They don't provide a rich enough event model for applications. 
For example, they support only the notion that something has changed, 
but they don't convey any information about what has changed. 
There are also some thread-safety and sequencing issues that cannot be fixed compatibly. 
@mtorchiano
mtorchiano / FibonacciStream.java
Last active March 13, 2022 15:33
Fibonacci sequence generation using Java Stream API
package streams;
import java.util.stream.LongStream;
import java.util.stream.Stream;
public class FibonacciStream {
public static LongStream fibonacciGG() {
class FibonacciGenerator{
int prev=0;