Skip to content

Instantly share code, notes, and snippets.

Jeff Sheets jeffsheets

View GitHub Profile
jeffsheets /
Last active Apr 26, 2018
Bash Commands to Export Cert and Import into Java Truststore

Command to export a cert from a website to a .cer file (example uses Tested with git-bash shell on Windows. Assume similar on Mac?

openssl s_client -servername -connect </dev/null 2>/dev/null | openssl x509 -inform PEM -outform DER -out

Command to import into local java truststore (use your own location of JAVA_HOME)

"$JAVA_HOME"/bin/keytool -keystore "$JAVA_HOME"/jre/lib/security/cacerts -importcert -alias -file

jeffsheets / GwtSpockWidgetSpec.groovy
Last active Apr 30, 2018
GWT Spock test with GwtMockito for Google Web Toolkit client testing
View GwtSpockWidgetSpec.groovy
package com.sheetsj.myapp.client.widget.fancy
import com.sheetsj.myproj.client.AppController
import com.sheetsj.myproj.client.widget.ErrorWidget
import org.mockito.Mockito
import spock.lang.Specification
jeffsheets / ApiSecurityConfig.groovy
Created Sep 6, 2017
Spock Test for Spring Boot Security configuration - showing basic simple examples for unauthenticated users, role based access, and httpBasic logins
View ApiSecurityConfig.groovy
class ApiSecurityConfig extends WebSecurityConfigurerAdapter {
void configureGlobal(AuthenticationManagerBuilder auth) {
protected void configure(HttpSecurity http) {
jeffsheets / EmbeddedMariaDbConfig.groovy
Last active Jun 1, 2018
Embedded MariaDB4j Spring Boot Configuration
View EmbeddedMariaDbConfig.groovy
import ch.vorburger.mariadb4j.DBConfigurationBuilder
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import javax.sql.DataSource
jeffsheets / EMUserRepository.groovy
Last active Mar 23, 2017
UserRepository showing export false at type level, but export true at method level
View EMUserRepository.groovy
//Filed Spring Data Rest bug
//so check there for answers
@RepositoryRestResource(path='emUsers', exported = false)
interface EMUserRepository extends EnversRevisionRepository<EMUser, Long, Integer>, JpaSpecificationExecutor<EMUser> {
//Attempting, as an example, to expose only this /search/findByAuth0UserId endpoint
//but with @RepositoryRestResource(exported=false) this endpoint is not exported
//but with @RepositoryRestResource(exported=true) this endpoint is exported
@RestResource(exported = true)
jeffsheets / TreeTraversal.js
Created Aug 15, 2016
Javascript binary search, quick sort, depth first search, and breadth first search
View TreeTraversal.js
//See full source with HTML at jsfiddle:
function node(val, left, right) {
return {val: val, left: left, right: right, visited: false};
jeffsheets / BinarySearch.groovy
Created Aug 8, 2016
BinarySearch, QuickSort, DepthFirstSearch, BreadthFirstSearch in groovy
View BinarySearch.groovy
class BinarySearch {
def bfs(def node, def result=[]) {
Queue queue = new LinkedList()
while (queue) {
def it = queue.poll()
result << it.val
jeffsheets /
Created Jul 14, 2016
Worst FizzBuzz Ever in Java
import java.util.Arrays;
public class WorstFizzBuzzEver {
public static final String BUZZ = "Fizz";
public static final String FIZZ = "Buzz";
* This does Fizz Buzz
jeffsheets /
Created May 20, 2016
Use JPA 2.1 and Hibernate 4.3.11 on Websphere 8.5.5.x
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import javax.persistence.spi.PersistenceProvider;
import javax.persistence.spi.PersistenceProviderResolver;
import javax.persistence.spi.PersistenceProviderResolverHolder;
import java.util.Collections;
import java.util.List;
jeffsheets /
Created Mar 24, 2016
Spring MVC unit (minimal integration) test that uses Spring config for the controller setup
package org.springframework.web.servlet.handler
import org.springframework.web.context.WebApplicationContext
* Workaround to register a controller with the WebAppContext because detectHandlerMethods is protected
* This allows our Mvc Unit tests to use the wired up Spring Jackson converters and mappers,
* without having to specify them individually in every test
You can’t perform that action at this time.