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 / 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 / getFlatList.bash
Last active January 12, 2021 16:36
How to download FlatList and its related dependencies directly into your node_modules.
mkdir -p node_modules/react-native/Libraries/Lists/ && \
for file in 'FlatList' 'MetroListView' 'SectionList' 'VirtualizedList' 'VirtualizedSectionList' 'ViewabilityHelper' 'VirtualizeUtils'; \
do curl https://raw.githubusercontent.com/facebook/react-native/master/Libraries/Lists/${file}.js > node_modules/react-native/Libraries/Lists/${file}.js; \
done
@cooperka
cooperka / ListView to FlatList.diff
Last active June 18, 2020 05:36
Migrating from ListView to FlatList in React Native.
-import { Text, View, ListView } from 'react-native';
+import { Text, View, FlatList } from 'react-native';
import style from './styles';
import listData from './listData';
class App extends Component {
- constructor(props) {
- super(props);
@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 / 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 / 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);
}
/**
@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 / 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