Skip to content

Instantly share code, notes, and snippets.

View Sch3lp's full-sized avatar
🐚

Tim Schraepen Sch3lp

🐚
View GitHub Profile
@Sch3lp
Sch3lp / DropWizardHibernateRule
Last active August 29, 2015 13:56
Dropwizard-hibernate integration test using a Rule
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;
@Sch3lp
Sch3lp / CustomerRepository
Last active August 29, 2015 13:57
dropwizard-hibernate issue: our setup
public class CustomerRepository extends AbstractDAO<Customer> {
public CustomerRepository(SessionFactory sessionFactory) {
super(sessionFactory);
}
public List<Customer> getAll() {
return list(namedQuery(Customer.QUERY_ALL));
}
### 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 / app.js
Last active December 25, 2015 10:39
The twitchServices module has a method that allows a caller to get all the Streams. The service uses Angulars Promises: $q.defer(); The thing that I got stuck on was the $rootScope.$apply() wrapper block. If you don't do this then Angular's models won't be updated automagically. Another caveat was the fact that Twitch.SDK's 'streams' method retu…
'use strict';
angular.module('twitchSmartTvApp', ['twitchServices'])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'main.html',
controller: function ($scope, Streams) {
$scope.streams = Streams.getAll();
}
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 / .bash_profile
Created June 8, 2016 16:43 — forked from natelandau/.bash_profile
Mac OSX 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
@Sch3lp
Sch3lp / SettlementMockitoTest.java
Last active December 6, 2016 14:17
Example of tight coupling between Test and Implementation with Mockito, aka Mockitis
@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 / Tests.elm
Last active July 10, 2017 22:27
Elm's List.sortBy in reversed order is a PITA, help me fix my ignorance
module Tests exposing (..)
import Test exposing (..)
import Expect
all : Test
all =
describe "sortBy tests"
[ dafuq ]
@Sch3lp
Sch3lp / Primes.kt
Last active December 18, 2019 14:27
Sieve of Eratosthenes
// 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 / ValidationError.java
Last active March 16, 2020 07:23
VinValidator
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) {