- About the (simple) exercise
- Higher Order Functions
- Throwing exceptions: here be dragons!!
- Sentinel values: better but not great
- The
Option
: error as an ADT - Functional combinators: add some sugar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.utkuozdemir.json | |
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter | |
import com.fasterxml.jackson.core.util.Separators | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import org.junit.jupiter.api.Test | |
data class Person(val name: String, val age: Int) | |
class CustomPrettyPrinter : DefaultPrettyPrinter() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.time.LocalDate; | |
import java.time.ZoneId; | |
import java.util.Date; | |
/** | |
* This pattern has the following benefits: | |
* | |
* - Date formats are referenced as a strong type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//JAVA 16 | |
//JAVAC_OPTIONS -source 16 | |
//DEPS info.picocli:picocli:4.6.1 | |
//DEPS io.javalin:javalin:3.13.9 | |
//DEPS org.neo4j.driver:neo4j-java-driver:4.3.3 | |
//DEPS org.neo4j:neo4j-graphql-java:1.3.0 | |
//DEPS com.fasterxml.jackson.core:jackson-databind:2.10.5 | |
//DEPS org.slf4j:slf4j-simple:1.7.31 | |
package com.example.graphqlplain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: GraalVM Native Image build | |
on: | |
push: | |
branches: [ master ] | |
tags: [ '*' ] |
- Programming using a series of transformations and aggregations, something I've been doing for years, is known as programming in the map/reduce style.
- The more abstract the type is, the greater its cardinality, and the smaller the set of operations it supports. So make use of universal quantifiers, particularly by implementing fully parametric functions. They guide you on how to implement their term-level definitions by narrowing down the number of possible implementations. In other words, the type system of Scala (or Haskell, for that matter) is not only great for capturing compile-time errors, but is also capable of leading you to the correct solution.
- You can encode union types by combining different Scala features such as type constructors, subtyping and implicits, and by taking advantage of the Curry-Howard Isomorphism and De Morgan's Laws for neg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env curl -LSs https://sh.jbang.dev | bash -s - "$0" "$@"; exit $? | |
//DEPS org.springframework.boot:spring-boot-starter-web:2.3.4.RELEASE | |
import org.springframework.web.bind.annotation.*; | |
import org.springframework.boot.*; | |
import org.springframework.boot.autoconfigure.*; | |
import org.springframework.context.*; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.context.annotation.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class ChunkedStreams { | |
private ChunkedStreams(){} | |
@SuppressWarnings("SameParameterValue") | |
public static <T> Stream<List<T>> chunks(Stream<T> sourceStream, int size) { | |
var source = sourceStream.spliterator(); | |
return StreamSupport.stream(new Spliterator<>() { | |
final List<T> buf = new ArrayList<>(); | |
@Override | |
public boolean tryAdvance(Consumer<? super List<T>> action) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/* eslint-disable no-console */ | |
// npm i smtp-server | |
// npm i mailparser | |
// https://nodemailer.com/extras/smtp-server/ | |
// https://nodemailer.com/extras/mailparser/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tasks.option | |
import org.scalatest.FunSuite | |
/** | |
* show some scala stuff that I found weird when I started this journey | |
* | |
* I'll use scala test as a vehicle, | |
* but this is not a talk about writing tests, so the tests themselves will be a little repetitive. | |
* I'll be using a very basic subset of the library, the library has lots of features. |
NewerOlder