Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Sheets jeffsheets

View GitHub Profile
@jeffsheets
jeffsheets / PapioMenuAlexaAppPrivacyPolicy.txt
Last active Feb 19, 2021
Papio Menu Alexa App Privacy Policy
View PapioMenuAlexaAppPrivacyPolicy.txt
The Papio Menu Alexa app available on Amazon Alexa does NOT collect any information.
The app is free for anyone to use on Alexa
@jeffsheets
jeffsheets / ColumnRowMapper.java
Last active Jan 25, 2021
Use Spring JdbcTemplate to easily read data, without Spring Data JPA, and map columns using Column DTO mappings, using a secondary database connection
View ColumnRowMapper.java
/** Based nearly completely on this same code from https://stackoverflow.com/a/52534584/1469525 */
@Slf4j
public class ColumnRowMapper<T> extends BeanPropertyRowMapper<T> {
private ColumnRowMapper(final Class<T> mappedClass) { super(mappedClass); }
@Override
protected String underscoreName(final String name) {
final Column annotation;
final String columnName;
@jeffsheets
jeffsheets / LocalDataSetup.java
Last active Dec 31, 2020
Spring Boot Initialize Local Test Data on Startup
View LocalDataSetup.java
/** Shows how to use code to init data instead of using data.sql or import.sql with Spring Boot */
@Component
@Profile({"local", "test"})
@RequiredArgsConstructor //Lombok magic to autowire the final fields (optional)
public class LocalDataSetup implements ApplicationRunner {
private final MyObjectRepository myObjectRepository;
@Override
public void run(ApplicationArguments args) {
@jeffsheets
jeffsheets / Jenkinsfile
Created Dec 8, 2020
Minimal Gradle Jenkinsfile
View Jenkinsfile
//Inspired by https://gist.github.com/aerobless/37561bb0fb45b7e8732beaafad1cba26
pipeline {
agent any
triggers {
//Needed by Bitbucket to see the builds on PRs https://stackoverflow.com/a/54710254
pollSCM('')
}
stages {
@jeffsheets
jeffsheets / email.html
Last active Oct 2, 2019
HTML Email structure and CSS hacks
View email.html
<!--
* A collection of various HTML Email hacks
** Along with these, user an html boilerplate like https://github.com/seanpowell/Email-Boilerplate
** Hacks are from many sources including:
** https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design
** https://litmus.com/community/discussions/1007-outlook-image-sizes
** https://www.emailonacid.com/blog/article/email-development/how-to-code-emails-for-outlook-2016/
-->
<!-- 1) Fix image sizes in Outlook -->
@jeffsheets
jeffsheets / 1-websyncConfig.js
Last active Jan 25, 2021
AWS S3 Deploy sync w/ Cloudfront Invalidation and Cache-Control headers for Create-React-App
View 1-websyncConfig.js
//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" },
@jeffsheets
jeffsheets / .env.development
Last active Jun 26, 2019
JS to read AWS SSM variables for use in Gitlab CI process
View .env.development
#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 / _ReactIntl_CreatReactApp.md
Last active Dec 30, 2019
Create React App CRA2 with react-intl i18n message extraction and translation
View _ReactIntl_CreatReactApp.md

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 / GroovySQLWithSpringDAO.groovy
Last active Oct 28, 2020
Using Groovy SQL with Spring configured Datasource to call complicated stored procedures with multiple ResultSets and multiple In and Out Params
View GroovySQLWithSpringDAO.groovy
@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 / 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
@Service
class ClientJWTService {
@Value('${client.publicKey}')
String publicKeyString
@Value('${client.privateKey}')
String privateKeyString
Algorithm buildJwtAlgorithm() {
KeyFactory kf = KeyFactory.getInstance('RSA')