Skip to content

Instantly share code, notes, and snippets.

@BenArunski
BenArunski / Victim.java
Created October 4, 2017 14:47
Equals / Hashcode for lookup table
package us.ne.state.nsc.npacs.businessobject;
import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import us.ne.state.nsc.npacs.lookup.VictimizationTypeLookup;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@BenArunski
BenArunski / LookupConverterTemplate.java
Last active January 7, 2018 17:17
JSF Lookup SelectItem cheat sheet
package us.ne.state.nsc.npacs.lookupbean;
import org.springframework.data.jpa.repository.JpaRepository;
import us.ne.state.nsc.npacs.lookup.NpacsLookup;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
@BenArunski
BenArunski / index.html
Created July 13, 2016 17:45
Angular Environment Bootstrap with ui-router
<html>
<body>
...
<script>
(function() {
'use strict';
var cb = function (cfg) {
angular.module('app.config', []).constant('CONFIG', cfg);
angular.element(document).ready(function() {
// instead of <html ng-app="main">
@BenArunski
BenArunski / TodoController.java
Created January 4, 2016 06:42
ToDo controller (cross-site)
package hello;
import static java.util.Collections.synchronizedList;
import static org.apache.http.HttpStatus.SC_BAD_REQUEST;
import static org.apache.http.HttpStatus.SC_NOT_FOUND;
import static org.apache.http.HttpStatus.SC_OK;
import static org.apache.http.HttpStatus.SC_UNPROCESSABLE_ENTITY;
import static org.springframework.web.bind.annotation.RequestMethod.DELETE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.OPTIONS;
@BenArunski
BenArunski / InternalServerErrorException.java
Last active February 17, 2016 17:03
Spring RestController + Rest-Assured + Spock
package hello;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR, reason = "There was an unexpected server exception")
public class InternalServerErrorException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
@BenArunski
BenArunski / TimeSpan.java
Created December 18, 2015 21:29
Utility class for detecting span overlaps
import java.util.Date;
public class TimeSpan {
private final Date start;
private final Date end;
public TimeSpan(Date start, Date end) {
if (start != null && end != null && end.before(start)) {
this.start = end;
this.end = start;