Skip to content

Instantly share code, notes, and snippets.

View jwgmeligmeyling's full-sized avatar
🚀

Jan-Willem Gmelig Meyling jwgmeligmeyling

🚀
View GitHub Profile
@jwgmeligmeyling
jwgmeligmeyling / Circle.java
Last active August 29, 2015 14:07
Circle interface using Java default methods
package nl.tudelft.ti2206.bubbles;
import java.awt.Point;
/**
* Circle
*
* @author Jan-Willem Gmelig Meyling
*
*/
@jwgmeligmeyling
jwgmeligmeyling / DatabaseModule.java
Last active May 27, 2020 16:53
Test Guice projects using the JPAPersistModule with Jukito
import javax.persistence.EntityManager;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.persist.PersistService;
import com.google.inject.persist.jpa.JpaPersistModule;
public class DatabaseModule extends AbstractModule {
@jwgmeligmeyling
jwgmeligmeyling / MultimapCollector.java
Last active September 27, 2020 10:16
Collectors for Guava Multimaps
package nl.tudelft.ewi.gitolite.config.util;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.TreeMultimap;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Value;
@jwgmeligmeyling
jwgmeligmeyling / search-param.js
Created November 22, 2015 23:17
Location search parameters for Angular
/**
* Angular Module that exposes the search parameters for the current window location.
* For example: http://localhost/?test=1
* Exposes: $searchParams.test === 5
* This is different than the search method in the $location service, which only exposes search params set in the location hash.
*
*/
angular.module('org.searchparams').service('$searchParams', function() {
window.location.search.substring(1)
.split("&")
@jwgmeligmeyling
jwgmeligmeyling / DateTest.java
Created January 20, 2016 21:43
Some tests on basic assumptions on Java's LocalDateTime
import org.junit.Test;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneId;
import static org.junit.Assert.assertEquals;
/**
package nl.tudelft.cucumber;
import java.io.Closeable;
public class Calculator implements Closeable {
public int add(int a, int b) {
return a + b;
}
@jwgmeligmeyling
jwgmeligmeyling / DatabaseTestModule.java
Created May 18, 2016 22:19
Persisting recursive relationships with Hibernate
package org.hibernate.test;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.persist.PersistService;
import com.google.inject.persist.jpa.JpaPersistModule;
public class DatabaseTestModule extends AbstractModule {
@jwgmeligmeyling
jwgmeligmeyling / README.md
Created May 29, 2016 22:29
Angular bind checkbox model to array

Angular bind checkbox model to array

Angular model formatter and parser pair that transforms a set of checkboxes to an array filled with arbitrary values.

Usage

<input type="checkbox" ng-model="ctrl.myModel" data-multi-select-value="::arrayValue">
@jwgmeligmeyling
jwgmeligmeyling / MergeUtil.java
Created November 7, 2016 18:59
Merge functions for solving duplicate keys in toMap collectors
package nl.meylingmedia.util;
import java.util.Comparator;
import java.util.function.BinaryOperator;
import java.util.function.Function;
/**
* Merge functions for solving duplicate keys in toMap collectors.
*
* @see java.util.stream.Collectors#toMap(Function, Function, BinaryOperator)
@jwgmeligmeyling
jwgmeligmeyling / TableCollector.java
Last active January 16, 2017 23:28
Guava Table Collector
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.google.common.collect.Table.Cell;
import com.google.common.collect.TreeBasedTable;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Value;
import lombok.experimental.Accessors;
import java.util.Collections;