Skip to content

Instantly share code, notes, and snippets.

#### Issue description
#### System Info
- OS?
- Browser?

Keybase proof

I hereby claim:

  • I am KevinSalter on github.
  • I am kevinsalter (https://keybase.io/kevinsalter) on keybase.
  • I have a public key whose fingerprint is 589E 8D1E A4D8 F3E7 B23A 2013 439E B75C C719 B6CF

To claim this, I am signing this object:

import { assert } from 'chai';
import { ActionsObservable } from 'redux-observable';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/toArray';
import saveFieldEpic from './saveField.js';
@kevinsalter
kevinsalter / configureStore.js
Created November 20, 2016 05:00
Injecting the Observable.ajax dependency in combineEpics before calling createEpicMiddleware
import { createStore, applyMiddleware } from 'redux';
import { createEpicMiddleware, combineEpics } from 'redux-observable';
import { ajax } from 'rxjs/observable/dom/ajax';
import RootReducer from './reducers';
import saveFieldEpic from './epics/saveFieldEpic.js';
const rootEpic = (...args) => combineEpics(
saveFieldEpic,
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/startWith';
import {
isSaving, savingSuccess, savingError,
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/dom/ajax';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/startWith';
import {
/**
* ellipsisify
* @param {string} filename - The filename to be truncated.
* @param {number} lengthThreshold - (optional) The minimum length of filename to truncate.
*/
export const ellipsisify = (filename, lengthThreshold = 20) => {
// just return the filename if it's less than 20 characters long
if (filename.length < lengthThreshold) return filename;
@kevinsalter
kevinsalter / array-spread-reordering.js
Last active June 25, 2023 12:04
reordering array using ES2015 array spread operator
const reorderArray = (event, originalArray) => {
const movedItem = originalArray.find((item, index) => index === event.oldIndex);
const remainingItems = originalArray.filter((item, index) => index !== event.oldIndex);
const reorderedItems = [
...remainingItems.slice(0, event.newIndex),
movedItem,
...remainingItems.slice(event.newIndex)
];
@kevinsalter
kevinsalter / naive-reordering.js
Last active February 6, 2019 18:53
naive array re-ordering
const getReorderedQuestions = (event, questions) => {
const movedQuestion = questions.find((question, index) => index === event.oldIndex);
const remainingQuestions = questions.filter((question, index) => index !== event.oldIndex);
const reorderedQuestions = [];
remainingQuestions.forEach((question, index) => {
if (index === event.newIndex) {
reorderedQuestions.push(movedQuestion);
reorderedQuestions.push(question);
} else {
@kevinsalter
kevinsalter / main-view.spec.jsx
Created May 27, 2016 16:45
<MainView /> unit tests
import React from 'react';
import {shallow} from 'enzyme';
import {assert} from 'chai';
import {spy} from 'sinon';
import MainView from '../src/main-view.js';
import {Users} from '../fixtures/users.js';
describe('<MainView />', () => {
const MAIN_VIEW_PROPS = {