Skip to content

Instantly share code, notes, and snippets.

Avatar
🐚

Tim Schraepen Sch3lp

🐚
View GitHub Profile
View ValidationError.java
import java.util.Objects;
public class ValidationError {
private final String error;
private ValidationError(final String error) {
this.error = error;
}
public static ValidationError from(final String error) {
@Sch3lp
Sch3lp / Primes.kt
Last active Dec 18, 2019
Sieve of Eratosthenes
View Primes.kt
// https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
val primes: Sequence<Int> = sequence {
var numbers = generateSequence(2) { it + 1 }
while (true) {
val prime = numbers.first()
yield(prime)
numbers = numbers
.drop(1)
.filter { it % prime != 0 }
@Sch3lp
Sch3lp / Tests.elm
Last active Jul 10, 2017
Elm's List.sortBy in reversed order is a PITA, help me fix my ignorance
View Tests.elm
module Tests exposing (..)
import Test exposing (..)
import Expect
all : Test
all =
describe "sortBy tests"
[ dafuq ]
@Sch3lp
Sch3lp / SettlementMockitoTest.java
Last active Dec 6, 2016
Example of tight coupling between Test and Implementation with Mockito, aka Mockitis
View SettlementMockitoTest.java
@RunWith(MockitoJUnitRunner.class)
public class SettlementMockitoTest {
@Test
public void settlement_WhenMoreSettlersAssignedToDefenseThanAmountOfRaiders_CanDefendItself() throws Exception {
Raiders raiders = mock(Raiders.class);
when(raiders.getAmountOfRaiders()).thenReturn(1);
Settler defender = mock(Settler.class);
Settler farmer = mock(Settler.class);
@Sch3lp
Sch3lp / .bash_profile
Created Jun 8, 2016 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
View .bash_profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
View FileFormatterTest.java
package be.schelp.example;
import org.junit.Rule;
import org.junit.Test;
import org.joda.time.DateMidnight;
import static org.assertj.core.api.Assertions.assertThat;
import be.schelp.test.FreezeDateRule;
public class FileFormatterTest {
@Sch3lp
Sch3lp / SharedTestSourceSet.md
Last active Feb 1, 2022
Custom SourceSet for exposing TestBuilders through a shared-test jar using Gradle
View SharedTestSourceSet.md

#Context We have a project set-up of:

project-A
  a-services-api
  a-services-impl
project-B
  b-services-api
  b-services-impl
non-gradle-project-C
View gist:f2677eb19aeb6dae9a11
### Keybase proof
I hereby claim:
* I am sch3lp on github.
* I am sch3lp (https://keybase.io/sch3lp) on keybase.
* I have a public key whose fingerprint is 6A5E A0B7 A502 BCC7 B04D 768C FB9E E221 BB80 CEF6
To claim this, I am signing this object:
@Sch3lp
Sch3lp / CustomerRepository
Last active Aug 29, 2015
dropwizard-hibernate issue: our setup
View CustomerRepository
public class CustomerRepository extends AbstractDAO<Customer> {
public CustomerRepository(SessionFactory sessionFactory) {
super(sessionFactory);
}
public List<Customer> getAll() {
return list(namedQuery(Customer.QUERY_ALL));
}
@Sch3lp
Sch3lp / DropWizardHibernateRule
Last active Aug 29, 2015
Dropwizard-hibernate integration test using a Rule
View DropWizardHibernateRule
package org.yourcompany.test;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import javax.sql.DataSource;