Skip to content

Instantly share code, notes, and snippets.

View roamingthings's full-sized avatar

Alexander Sparkowsky roamingthings

View GitHub Profile
@roamingthings
roamingthings / supertest_chaining.ts
Created November 29, 2019 09:04
Chain of requests using Supertest.js
describe('Chain calls to an api', () => {
it('should perform all requests subsequentially', done => {
request(app)
.get('/api/first')
.expect(200)
.end((err: any, res: Response) => {
if (err) return done(err);
const action = res.text
request(app).get('/api/second')
.query({ action })
@roamingthings
roamingthings / ReinitializingLoggingSystemTest.kt
Created December 2, 2020 17:09
How to re-initialize the Spring Boot Logging System in a Spring Boot 2.4 Test
@SpringBootTest
@TestPropertySource(properties = ["logging.config=classpath:logback-other.xml"])
@ContextConfiguration(initializers = [LoggingSystemReinitializer::class])
class LoggingMaskingDecoratorTest {
private val standardOut = System.out
private val outputStreamCaptor: ByteArrayOutputStream = ByteArrayOutputStream()
companion object {
@AfterAll
@roamingthings
roamingthings / build.gradle.kts
Created November 23, 2019 19:10
Gradle build file for Kotlin library
import org.gradle.api.JavaVersion.VERSION_1_8
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
import java.time.Year
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
plugins {
`java-library`
@roamingthings
roamingthings / build.gradle.kts
Created September 28, 2019 09:50
Basic gradle kts script for a Spring Boot 2.1 application
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.1.8.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
kotlin("jvm") version "1.3.50"
kotlin("plugin.spring") version "1.3.50"
}
group = "de.roamingthings"

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@roamingthings
roamingthings / kubernetes_cheatsheet.adoc
Created March 15, 2018 08:36
A cheatsheet for Kubernetes

Kubernetes Cheatsheet

Minikube

Start
$ minikube start
@roamingthings
roamingthings / init_postgres.sh
Created July 21, 2016 09:38
This script creates a Docker container running a PostgreSQL database. The data is stored on the host so it survives container re-creation. Finally `pgsql` client is executed and connects to the created container (mostly for demonstration purpose).
#! /bin/bash
# Author: Alexander Sparkowsky
# Email: info@roamingthings.de
# License: MIT
# Usage: ./init_postgres.sh _project_name_ _db_password_ _[host_path_db_data]_ _[pg_docker_image_name]_
PROJECT_NAME=$1
DB_NAME="$PROJECT_NAME"
HOST_PATH_DB_DATA=${3:-"/tmp/postgres/data/$DB_NAME"}
@roamingthings
roamingthings / Jackson 2 `ObjectMapper` initialization.java
Created June 7, 2016 08:19
Code snippets to use a Jackson 2 `ObjectMapper` and `JsonNode` to generate JSON documents.
ObjectMapper objectMapper = new ObjectMapper()
// Find and register modules e.g. for serialization or JAXB annotation processing
.findAndRegisterModules()
// Order map entries by key
.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
// Don't fail on empty beans
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
// Write date values as timestamp instead of ms since epoch
.enable(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS)
// Don't include default view / non @JsonView annotaded values
@roamingthings
roamingthings / MyEntity.java
Created April 14, 2016 04:28 — forked from thjanssen/MyEntity.java
Persisting Java 8 DateTime API with Hibernate 5
@Entity
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", updatable = false, nullable = false)
private Long id;
@Column
private LocalDate date;
@roamingthings
roamingthings / .gitignore_java
Created January 3, 2014 10:59
Basic .gitignore files for various kinds of projects
#
# Basic .gitignore file for Java projects using eclise, IntelliJ and maven
#
# Eclipse
.classpath
.project
.settings/
# Intellij