Skip to content

Instantly share code, notes, and snippets.

@jeffsheets
jeffsheets / exportImportJavaCert.md
Last active April 6, 2023 16:29
Bash Commands to Export Cert and Import into Java Truststore

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

openssl s_client -servername google.com -connect google.com:443 </dev/null 2>/dev/null | openssl x509 -inform PEM -outform DER -out google.com.cer

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

"$JAVA_HOME"/bin/keytool -keystore "$JAVA_HOME"/lib/security/cacerts -importcert -alias google.com -file google.com.cer

@jeffsheets
jeffsheets / photoBackup.md
Last active May 31, 2018 01:09
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

Requirements

  • 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
jeffsheets / PersonControllerIntProxiedSpec.groovy
Last active May 31, 2018 03:46
Spock 1.2 Spring Integration Test annotations SpringBean, SpringSpy, UnwrapAopProxy
import org.springframework.test.util.AopTestUtils
/** Showing how to unwrap the AOP proxy manually to reuse the cached Spring context config */
@Import([IntegrationTestMockingConfig])
class PersonControllerIntProxiedTest extends Specification {
@Autowired MockMvc mvc
/** A simple mock can just be autowired */
@Autowired ExternalRankingService externalRankingServiceMock
@jeffsheets
jeffsheets / SpringConsulRibbonContextPathConfig.groovy
Created June 14, 2018 16:57
Spring Config for RestTemplate to use contextPath from Consul
/**
* Workaround to let RestTemplate use the contextPath from Consul when calling URLs
* (instead of only using the host and port)
* See https://github.com/spring-cloud/spring-cloud-consul/issues/376
*
* Put this in any spring config class
*/
@Bean
LoadBalancerRequestTransformer consulContextPathTransformer() {
@jeffsheets
jeffsheets / JsonDotNetLocalDateTimeDeserializer.groovy
Created September 26, 2018 19:24
Groovy Jackson Deserializer to convert a .NET style JSON dateTime to a Java LocalDateTime object
class JsonDotNetLocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
@Override
LocalDateTime deserialize(JsonParser parser, DeserializationContext ctxt) {
convertDotNetDateToJava(parser.text.trim())
}
/**
* Returns a Java LocalDateTime when given a .Net Date String
* /Date(1535491858840-0500)/
@jeffsheets
jeffsheets / ClientJWTService.groovy
Last active March 24, 2021 02:00
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
@Service
class ClientJWTService {
@Value('${client.publicKey}')
String publicKeyString
@Value('${client.privateKey}')
String privateKeyString
Algorithm buildJwtAlgorithm() {
KeyFactory kf = KeyFactory.getInstance('RSA')
@jeffsheets
jeffsheets / GroovySQLWithSpringDAO.groovy
Last active October 28, 2020 01:46
Using Groovy SQL with Spring configured Datasource to call complicated stored procedures with multiple ResultSets and multiple In and Out Params
@Slf4j
@Component
class GroovySQLWithSpringDAO {
@Autowired
Sql groovySql
List<GroovyRowResult> findByFirstLast(String firstName, String lastName) {
GString statement = """{call FIND_BY_FIRST_LAST_SP (
${firstName}, ${lastName}, 'SYSUSER',
${Sql.INTEGER}, ${Sql.VARCHAR}, ${Sql.VARCHAR}, ${Sql.VARCHAR}
@jeffsheets
jeffsheets / _ReactIntl_CreatReactApp.md
Last active December 30, 2019 22:41
Create React App CRA2 with react-intl i18n message extraction and translation

i18n Translations

To generate new translations:

  1. remove .messages folder
  2. Extract all messages into .messages dir with: yarn i18n:extract
  3. Add new messages into {lang}.json files with: yarn i18n:manageTranslations
  4. Translate any new entries in {lang}.json files and commit to repo (see Untranslated keys: output of previous command for list of keys needing translation)

Setup

@jeffsheets
jeffsheets / .env.development
Last active May 25, 2023 05:50
JS to read AWS SSM variables for use in Gitlab CI process
#This is used locally by Create-React-App during development
#Cognito Region
REACT_APP_REGION=us-east-1
REACT_APP_USER_POOL_ID=us-east-1_youruserpoolid
REACT_APP_APP_CLIENT_ID=yourcognitoappclientidgoeshere
@jeffsheets
jeffsheets / 1-websyncConfig.js
Last active January 25, 2021 22:42
AWS S3 Deploy sync w/ Cloudfront Invalidation and Cache-Control headers for Create-React-App
//Config for s3 websync with cloudfront invalidation
// and Cache-Control headers for a Create-React-App application
//https://www.npmjs.com/package/websync
module.exports = {
source: "build/",
target: `s3://yourcompany-us-east-1-${process.env.CI_ENVIRONMENT_NAME}-createreactapp/`,
invalidateDeletes: true,
modifiers: {
"static/**": { CacheControl: "max-age=31536000" },