Skip to content

Instantly share code, notes, and snippets.

View cooperka's full-sized avatar

Kevin Cooper cooperka

View GitHub Profile
@cooperka
cooperka / fhir-uscdi-tutorial.md
Last active February 16, 2024 18:47
Auto-select all FHIR APIs listed within the USCDI core data set

Auto-select all FHIR APIs listed within the USCDI core data set

Automatic Client ID Distribution for USCDI depends on you selecting a limited subset of FHIR resources, but it's painful to manually cross-reference to select exactly which ones (Epic documentation is here with the full list). Automated solution:

  1. Create a new app at https://fhir.epic.com/Developer/Apps

  2. On the edit page, deselect any selected APIs, and run in browser console:

$("#WebServicesChosen option[data-uscdi-readonly=True]").each((i, item) => {

@cooperka
cooperka / Redux (vanilla) vs Redux (hooks-for-redux) comparison.md
Last active June 6, 2020 00:06
Redux (vanilla) vs Redux (hooks-for-redux) comparison

Vanilla Redux

Learn more

// Action type.
const ADD_TODO = 'ADD_TODO';

// Action creator.
function addTodo(todo) {
@cooperka
cooperka / Redux vs MobX comparison.md
Last active June 5, 2020 23:13
Redux vs MobX comparison

Redux

// Action type.
const ADD_TODO = 'ADD_TODO';

// Action creator.
function addTodo(todo) {
  return { type: ADD_TODO, todo };
}
@cooperka
cooperka / 01_install_yarn.config
Created June 18, 2018 23:50
AWS Elastic Beanstalk - Replace npm with yarn
# .ebextensions/01_install_yarn.config
files:
'/opt/elasticbeanstalk/hooks/appdeploy/pre/49install_yarn.sh' :
mode: '000755'
owner: root
group: root
content: |
#!/usr/bin/env bash
set -euxo pipefail
@cooperka
cooperka / __mocks__\react-redux.js
Last active March 22, 2018 02:42
Jest helper for Redux component testing
const mockDispatch = () => {};
function mapEverything(mapStateToProps, mapDispatchToProps, mergeProps, state, ownProps) {
const stateProps = mapStateToProps
? mapStateToProps(state, ownProps)
: {};
const dispatchProps = mapDispatchToProps
? mapDispatchToProps(mockDispatch, ownProps)
: {
@cooperka
cooperka / React redux component structure.md
Last active May 2, 2019 23:28
How I personally organize my React components.
src/
  index.js                # Renders an <App /> component.
  reducers.index.js       # Exports a root Redux reducer (or MobX store).

  components/
    MyComponent/
      component.js        # Exports MyComponent.
      component.test.js   # Contains tests.
      actions.js          # Exports Redux "action type" strings and "action creator" functions.
@cooperka
cooperka / Pull directly from PRs.sh
Created July 19, 2017 15:00
A one-time setup to fetch code directly from GitHub PRs, so you don't need to download their fork or figure out their branch name.
# One-time setup
git config --global --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git config --global --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" # This is the important one
# Make sure there aren't duplicate configs
git config --global --list
# Checkout someone else's PR!
git fetch origin
git checkout pr/20
@cooperka
cooperka / Expo error.html
Last active July 17, 2017 19:27
Expo error trying to run the react-navigation NavigationPlayground example app
<!doctype html5>
<html>
<head>
<style type="text/css">
strong { font-weight: bold; }
hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; }
html { font-family: sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; } body { margin: 0; }
a { background-color: transparent; }
a:active, a:hover { outline: 0; }
@cooperka
cooperka / emoji-utils.js
Last active April 11, 2017 15:16
"Pure emoji string" detection
import emojiRegexCreator from 'emoji-regex';
const emojiRegex = emojiRegexCreator();
export default {
isPureEmojiString(text) {
if (!text || !text.trim()) return false;
return text.replace(emojiRegex, '').trim() === '';
@cooperka
cooperka / SyncManager.js
Last active December 9, 2018 17:59
This is why I love redux-saga + ES6 generators.
/**
* Root sagas can be exported from every file, and are all bundled together in one master saga.
* This saga listens for requests to sync, as well as failure events.
*/
export default function* rootSaga() {
yield fork(takeLatest, cacheManagerActionTypes.SYNC_ALL, startSync);
yield fork(takeLatest, cacheManagerActionTypes.SYNC_FAILED, showSyncFailed);
}
/**