Skip to content

Instantly share code, notes, and snippets.

View helpermethod's full-sized avatar
⌨️
hacking

Oliver Weiler helpermethod

⌨️
hacking
View GitHub Profile
@utkuozdemir
utkuozdemir / JsonTest.kt
Last active October 27, 2022 07:45
Kotlin + Jackson Pretty Print Override
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() {
@dblevins
dblevins / Dates.java
Last active March 14, 2022 15:40
Legacy Java 7 version. See recommended Java 8 version https://gist.github.com/dblevins/47f7508e241d775fd7007a4639d6565a
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
@marc0der
marc0der / README.md
Last active February 18, 2022 14:17

Functional error handling in Kotlin

Agenda:

  • 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
@michael-simons
michael-simons / Neo4jGraphqlJava.java
Last active September 15, 2022 12:23
Brings up a Neo4jGraphQL Java server.
///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;
@linux-china
linux-china / graalvm.yml
Last active October 21, 2022 13:00
Github actions for GraalVM native image build on Windows, Mac and Linux. Please adjust 'demo-cli' to final name.
# 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: [ '*' ]
@melvic-ybanez
melvic-ybanez / what-i-didnt-know-about-fp-2020.md
Last active August 1, 2024 08:25
What I Didn't Know about Functional Programming until 2020

What I Didn't Know about Functional Programming until 2020

  1. Programming using a series of transformations and aggregations, something I've been doing for years, is known as programming in the map/reduce style.
  2. 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.
  3. 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
///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.*;
@chklauser
chklauser / ChunkedStreams.java
Last active May 2, 2022 15:22
A Java stream combinator that splits a stream into chunks of a fixed size. Last chunk in the stream might be smaller than the desired size. Ordering guarantees depend on underlying stream.
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) {
'use strict';
/* eslint-disable no-console */
// npm i smtp-server
// npm i mailparser
// https://nodemailer.com/extras/smtp-server/
// https://nodemailer.com/extras/mailparser/
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.