Skip to content

Instantly share code, notes, and snippets.

View holgergp's full-sized avatar

Holger Grosse-Plankermann holgergp

View GitHub Profile
@holgergp
holgergp / flatMapTest.sc
Last active December 15, 2020 13:45
Some fiddling with map, flatMap and foldLeft on Collections, Strings and Option. Trying to understand the generic monadic approach
object flatMapTest {
import scala.util.{ Try, Success, Failure }
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet
val intList = 1 :: 2 :: 5 :: Nil //> intList : List[Int] = List(1, 2, 5)
intList.map(x => x * 2) //> res0: List[Int] = List(2, 4, 10)
//intList.flatMap(x=>x*2) //type mismatch; found : Int required: scala.collection.GenTraversableOnce[?]
intList.foldLeft(0)((x, y) => x + y) //> res1: Int = 8
val stringList = "eins" :: "zwei" :: "drei" :: Nil
function zip(array1, array2) {
return array1.map(function (e, i) {
return [e, array2[i]];
});
}
function diff (a ,b) {
var zippedArray = zip(a,b);

Keybase proof

I hereby claim:

  • I am holgergp on github.
  • I am holgergp (https://keybase.io/holgergp) on keybase.
  • I have a public key ASButxv7UNML6Wo6IglzLmZUJurcndmI10Ukx0IywFe7Mwo

To claim this, I am signing this object:

#!/usr/bin/env groovy
@Grab('org.yaml:snakeyaml:1.17')
import org.yaml.snakeyaml.Yaml
import static groovy.io.FileType.FILES
def dir = new File("_posts");
def files = [];
@holgergp
holgergp / Ikea Payload
Last active May 2, 2019 12:30
IKEA PAX Save failed
{"itemList":{"item":[{"quantity":4,"itemNo":"50214560","itemType":"ART"},{"quantity":3,"itemNo":"30256891","itemType":"ART"},{"quantity":12,"itemNo":"70277957","itemType":"ART"},{"quantity":8,"itemNo":"30214504","itemType":"ART"},{"quantity":1,"itemNo":"60246396","itemType":"ART"},{"quantity":1,"itemNo":"90256893","itemType":"ART"},{"quantity":2,"itemNo":"79010992","itemType":"SPR"},{"quantity":8,"itemNo":"40298126","itemType":"ART"},{"quantity":8,"itemNo":"39010994","itemType":"SPR"}]},"application":"pax","configuration":{"content":{"planner":{"version":"2.49.0.3","dataVersion":"2","drawing":{"camera":{"dist":"0","yaw":"-0.0000017239695395455194","position":"-179.4447479248047,1056,-1820.9906005859375","pitch":"0.6984310787808502","lookAt":"-179.4448861453383,1000,2772.7406932388144"},"addons":{"products":""},"wallWidth":"6000","wallHeight":"3300","savedDate":"2019-5-2","floor":{"bitmapMaterial":{"id":"floor_0"}},"walls":{"wall":[{"wallVertices":{"vertex":[{"id":"15","type":"b","pos":"(x=-3000, y=2500)"},{"i
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80
@holgergp
holgergp / abstract.md
Created December 2, 2019 09:01
Abstract cucumber.js talk

Abstract

Cucumber.js - Starte den Tag mit BDD

Akzeptanztests in natürlicher Sprache für das Frontend? Und dann noch jedes Feature mit so einem Test beginnen? Lohnt sich das? Wenn man mich fragt: Ganz klar ja! Denn die Frontends, die wir heutzutage bauen, werden immer komplexer und da können wir jede Hilfe gebrauchen. Cucumber.js ist eine BDD-Testbibiothek, die es ermöglicht, solche Akzeptanztests in natürlicher Sprache zu schreiben und automatisiert in einem Client Build Workflow auszuführen. Ich möchte in meinem Vortrag zeigen, dass das Schreiben dieser Tests mit Cucumber.js gar nicht aufwändig sein muss und wie das Team davon profitiert, wenn dank dieser Tests Fachlichkeit und Technik näher zusammenrücken.

Vorkenntnisse:

@holgergp
holgergp / awaited.ts
Created December 9, 2021 17:14
Experiments with the new Awaited Type in Typescript
declare function MaybePromise<T>(value: T): T | Promise<T> | PromiseLike<T>
declare function MaybeNumberPromise(value: number): number | Promise<number> | PromiseLike<number>
declare type MaybePromiseType = ReturnType<typeof MaybeNumberPromise>
//Does not work at all!
async function doSomethingSpecial(): Awaited<[number, number]> {
const result = await Promise.all([MaybePromise(100), MaybePromise(200)]);
// Error!
@holgergp
holgergp / privateFieldPresenceCheck.ts
Last active January 14, 2022 09:42
Private Field Presence Checks (TypeScript 4.5 Article)
class Person {
#name: string;
constructor(name: string) {
this.#name = name;
}
equals(other: unknown) {
return other &&
typeof other === "object" &&
#name in other && // <- this is new!
this.#name === other.#name;
@holgergp
holgergp / importAssertions.ts
Last active January 14, 2022 09:45
Import Assertions (TypeScript 4.5 Article)
import obj from "./something.json" assert { type: "json" };