Skip to content

Instantly share code, notes, and snippets.

View mstepien's full-sized avatar

Martin mstepien

View GitHub Profile
@mstepien
mstepien / FunctionalDecoratorPattern.java
Last active March 3, 2017 21:53
Decorator Pattern done with function composition
Coffee coffee = Barista.makeCoffee(
new Arabica(),
Coffee::withMilk,
Coffee::withSprinkles);
System.out.println(
coffee.getIngredients()
+ ". Cost: "+
coffee.getCost());
@mstepien
mstepien / InitializeMapWithLambdaExample.java
Last active March 13, 2017 11:48
Initialize a Java Map with lambda
/**
* quick and neat way to initialize a Map since Java 8
*/
Map<Integer, String> map = Collections.unmodifiableMap(
Stream.of(
new SimpleEntry<>(0, "zero"),
new SimpleEntry<>(1, "one"),
new SimpleEntry<>(2, "two"),
new SimpleEntry<>(3, "three")
).collect(Collectors.toMap(
@mstepien
mstepien / drive-appscript.js
Last active January 1, 2016 17:59 — forked from igrigorik/drive-appscript.js
BigQuery queries for the HTTP Archive dataset with some Google BigQuery API code updates: - use of class QueryRequest - http://googleappsdeveloper.blogspot.com/2013/11/code-updates-required-for-apps-script.html
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Run Query", functionName: "runQuery"} ];
ss.addMenu("HTTP Archive + BigQuery", menuEntries);
}
function runQuery() {
var projectNumber = 'httparchive';
var sheet = SpreadsheetApp.getActiveSheet();