Skip to content

Instantly share code, notes, and snippets.

View apiv's full-sized avatar

Austin Pivarnik apiv

View GitHub Profile
import React, { Component }
import { Entities } from 'lib/api/module'
@Entities({
contactResource: {
type: 'contact',
getId: (passedProps) => passedProps.contactId
}
})
class MyComponent extends Component { /* ... */ }
// @flow
type Options = {
getId: (passedProps: {}) => string | string[]
}
const Entities = (options: Options) => /* ...code ... */
Entities({ getId: ({ contactId }) => Immutable.List([contactId]) })
// => throws a compiler error, return type of getId must be string | string[]
Entities({ getId: ({ contactId }) => contactId && [contactId] })
type Options = {
action: string,
type: string,
data: {},
params: {},
tolerance?: number,
debounce?: boolean
}
const performAction = (options: Options) => {
# Tab complete for ./git-merge-pr script
__git-merge-pr-complete()
{
local cur_word prev_word branch_list
# COMP_WORDS is an array of words in the current command line.
# COMP_CWORD is the index of the current word (the one the cursor is
# in). So COMP_WORDS[COMP_CWORD] is the current word; we also record
# the previous word here, although this specific script doesn't
# use it yet.
/* @flow */
import glob from 'glob'
/**
* writes a list of files matching the glob pattern to stdout
* runs only the subset of files which fall within the job, set
* in the environment variables.
*
* JOB_COUNT is the number of jobs we will be splitting across, 1-indexed
* JOB_INDEX is the index of the job (subset of files) we should be running, 0-indexed
{
"scripts": {
"test": "node ./node_modules/.bin/jest",
"test:ci": "yarn test --testMatch=$(babel-node ./scripts/parallelize.js)"
}
}
language: node_js
sudo: required
dist: trusty
node_js:
- '8'
env:
- JOB_COUNT=5 JOB_INDEX=0
- JOB_COUNT=5 JOB_INDEX=1
- JOB_COUNT=5 JOB_INDEX=2
/**
* Jest Conversion script
* This script isn't the cleanest, and uses two different methods for performing global replaces... but it gets the job done.
* We switched from using the `replace` method to the `advancedReplace` about 70% of the way through, and couldn't go and retrofit
* `advancedReplace` everywhere with 100% confidence. However, should you use this script as a base for your own migration,
* I would definitely suggest using `advancedReplace`, which uses the node-replace library.
*/
import {sync as globSync} from 'glob'
import {execSync} from 'child_process'
import fs from 'fs'