Skip to content

Instantly share code, notes, and snippets.

jeffsheets / FakeComponent.test.js
Last active December 30, 2023 23:30
testing-library set and get a react-select value
import React from 'react';
import { screen, render } from '@testing-library/react';
import selectEvent from 'react-select-event';
import CountryComponent from './FakeComponent';
describe('CountryComponent Test', () => {
test('form has value of selected option', async () => {
render(<CountryComponent />);
// react-select let's us update the select value by label, but you must select it by role 'textbox' not a 'select'
jeffsheets / timeZoneUtils.js
Last active November 5, 2021 02:49
Browser Javascript to get user timezone or offset that is IE11 safe when passed to a Java API, with Jest Test blogpost:
* Useful when passing the browser timezone to a backend Java API that reads a timezone in using ZoneId.of(tz),
* as both 'America/Chicago' and '-0600' are valid values when passed to the Java API.
* The Offset is used to handle IE11 and other older browsers.
export const getUserTimeZoneOrOffset = () => {
let timeZone;
try {
timeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch (error) {
jeffsheets / PapioMenuAlexaAppPrivacyPolicy.txt
Last active February 19, 2021 19:55
Papio Menu Alexa App Privacy Policy
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 /
Last active January 25, 2021 23:36
Use Spring JdbcTemplate to easily read data, without Spring Data JPA, and map columns using Column DTO mappings, using a secondary database connection
/** Based nearly completely on this same code from */
public class ColumnRowMapper<T> extends BeanPropertyRowMapper<T> {
private ColumnRowMapper(final Class<T> mappedClass) { super(mappedClass); }
protected String underscoreName(final String name) {
final Column annotation;
final String columnName;
jeffsheets /
Last active December 31, 2020 14:50
Spring Boot Initialize Local Test Data on Startup
/** Shows how to use code to init data instead of using data.sql or import.sql with Spring Boot */
@Profile({"local", "test"})
@RequiredArgsConstructor //Lombok magic to autowire the final fields (optional)
public class LocalDataSetup implements ApplicationRunner {
private final MyObjectRepository myObjectRepository;
public void run(ApplicationArguments args) {
jeffsheets / Jenkinsfile
Created December 8, 2020 22:31
Minimal Gradle Jenkinsfile
//Inspired by
pipeline {
agent any
triggers {
//Needed by Bitbucket to see the builds on PRs
stages {
jeffsheets / email.html
Last active April 18, 2022 02:19
HTML Email structure and CSS hacks
* A collection of various HTML Email hacks
** Along with these, user an html boilerplate like
** Hacks are from many sources including:
<!-- 1) Fix image sizes in Outlook -->
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
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 / .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
jeffsheets /
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)