Skip to content

Instantly share code, notes, and snippets.

View efenderbosch's full-sized avatar

Eric Fenderbosch efenderbosch

  • Ohio
  • 14:51 (UTC -04:00)
View GitHub Profile
@efenderbosch
efenderbosch / pom.xml
Last active December 17, 2015 22:09
maven build for mixed java and scala
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.yourcompany</groupId>
<artifactId>ProjectName</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<scalaVersion>2.10.1</scalaVersion>
</properties>
@efenderbosch
efenderbosch / gist:5699613
Last active December 18, 2015 00:49
maven install quickbooks
mvn install:install-file -DgroupId=com.intuit -DartifactId=ipp-java-devkit -Dversion=2.0.11 -Dpackaging=jar -Dfile=ipp-java-devkit-2.0.11-jar-with-dependencies.jar
mvn install:install-file -DgroupId=oauth.signpost -DartifactId=oauth-signpost -Dversion=1.2.1.2 -Dpackaging=jar -Dfile=signpost-core-1.2.1.2.jar
@efenderbosch
efenderbosch / SpringServiceInitializer.java
Created July 16, 2013 16:59
Initializes a Dropwizard Service health checks, resources, tasks, etc. using Spring @component annotations.
package com.segmint.postdelivery.spring;
import java.util.Map;
import javax.ws.rs.Path;
import javax.ws.rs.ext.Provider;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.apache.commons.lang.StringUtils;
public class Test {
public static void main(String[] args) throws Exception {
long time = Long.MAX_VALUE;
long shiftedTime = time << 23;
System.out.println("years " + Math.pow(2, 41) / 1000.0 / 60.0 / 60.0 / 24.0 / 365.0);
System.out.println("1234567890123456789012345678901234567890123456789012345678901234");
@efenderbosch
efenderbosch / Jdbc.java
Last active February 16, 2016 20:34
simple JDBC
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
public class Test {
public static void main(String[] args) throws Exception {
@efenderbosch
efenderbosch / JpaMapper.java
Last active August 29, 2015 14:00
JPA Mapper for Dropwizard
package com.segmint.jdbi;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
@efenderbosch
efenderbosch / EncryptablePropertiesPropertySource
Created January 12, 2015 14:39
Encryptable YAML for Spring Boot
public class EncryptablePropertiesPropertySource extends MapPropertySource {
@SuppressWarnings({ "unchecked", "rawtypes" })
public EncryptablePropertiesPropertySource(String name, Properties source) {
super(name, (Map) source);
}
protected EncryptablePropertiesPropertySource(String name, Map<String, Object> source) {
super(name, source);
}
@efenderbosch
efenderbosch / RedisTokenStore
Created January 19, 2015 20:27
Redis Token Store for Spring Security
public class RedisTokenStore implements TokenStore {
private static final StringRedisSerializer STRING_SERIALIZER = new StringRedisSerializer();
private static final ObjectMapper OBJECT_MAPPER = new JodaMapper().disable(WRITE_DATES_AS_TIMESTAMPS);
private final BoundHashOperations<String, String, OAuth2AccessToken> accessTokenStore;
private final BoundHashOperations<String, String, OAuth2AccessToken> authenticationToAccessTokenStore;
private final ListOperations<String, OAuth2AccessToken> userNameToAccessTokenStore;
private final ListOperations<String, OAuth2AccessToken> clientIdToAccessTokenStore;
private final BoundHashOperations<String, String, OAuth2RefreshToken> refreshTokenStore;
@efenderbosch
efenderbosch / PipelinedRedisTokenStore
Last active February 5, 2016 12:48
Pipelined Redis Token Store
package com.example
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
@efenderbosch
efenderbosch / NgnixEnvironmentController.java
Created February 10, 2015 14:52
Ngnix Config Controller
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.config.Environment;