Skip to content

Instantly share code, notes, and snippets.


Jeff Sheets jeffsheets

View GitHub Profile
jeffsheets / ClientJWTService.groovy
Last active Mar 24, 2021
JWT creation in Spring Boot Groovy or Java with RSA 512 or 256 algorithm including steps to generate the keys stored as strings in yml properties file
View ClientJWTService.groovy
class ClientJWTService {
String publicKeyString
String privateKeyString
Algorithm buildJwtAlgorithm() {
KeyFactory kf = KeyFactory.getInstance('RSA')
jeffsheets / JsonDotNetLocalDateTimeDeserializer.groovy
Created Sep 26, 2018
Groovy Jackson Deserializer to convert a .NET style JSON dateTime to a Java LocalDateTime object
View JsonDotNetLocalDateTimeDeserializer.groovy
class JsonDotNetLocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
LocalDateTime deserialize(JsonParser parser, DeserializationContext ctxt) {
* Returns a Java LocalDateTime when given a .Net Date String
* /Date(1535491858840-0500)/
jeffsheets / SpringConsulRibbonContextPathConfig.groovy
Created Jun 14, 2018
Spring Config for RestTemplate to use contextPath from Consul
View SpringConsulRibbonContextPathConfig.groovy
* Workaround to let RestTemplate use the contextPath from Consul when calling URLs
* (instead of only using the host and port)
* See
* Put this in any spring config class
LoadBalancerRequestTransformer consulContextPathTransformer() {
jeffsheets / PersonControllerIntProxiedSpec.groovy
Last active May 31, 2018
Spock 1.2 Spring Integration Test annotations SpringBean, SpringSpy, UnwrapAopProxy
View PersonControllerIntProxiedSpec.groovy
import org.springframework.test.util.AopTestUtils
/** Showing how to unwrap the AOP proxy manually to reuse the cached Spring context config */
class PersonControllerIntProxiedTest extends Specification {
@Autowired MockMvc mvc
/** A simple mock can just be autowired */
@Autowired ExternalRankingService externalRankingServiceMock
jeffsheets /
Last active May 31, 2018
Personal photo backup process

Personal Photo Backup Process

Just some notes so I can remember how I setup my phones to sync to my Crashplan backup on my PC


  • Backup pics from multiple iPhones
  • The backup should be wireless and automatic (or close)
  • Backup all files on PC to Crashplan
  • Extra points for backing up new photos to the same place as existing old photos and camera photos
jeffsheets /
Last active Sep 15, 2021
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 Apr 26, 2021
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)