This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FormComparer : IComparer<Box> | |
{ | |
public int Compare(Box x, Box y) | |
{ | |
int xCompare = GetIntForSize(x.Size); | |
int yCompare = GetIntForSize(y.Size); | |
return xCompare.CompareTo(yCompare); | |
} | |
private static int GetIntForSize(string size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const R = require('ramda') | |
const { Future } = require('ramda-fantasy') | |
const axios = require('axios') | |
const githubUrl = 'https://api.github.com/users/bpetersen' | |
const log = console.log.bind(console); | |
const error = console.error.bind(console); | |
const get = url => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//const data = ['one'] // ['one'] | |
//const data = ['one', 'two'] // ['one', ' and ', 'two'] | |
//const data = ['one', 'two', 'three'] // ['one', ', ', 'two', ' and ', 'three'] | |
const result = R.compose( | |
R.flatten, | |
R.intersperse(' and '), | |
R.reject(x => R.isEmpty(x) || R.isNil(x)), | |
R.map(R.intersperse(', ')) | |
)([R.init(data), [R.last(data)]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { connect } from 'react-redux' | |
import { Redirect } from 'react-router' | |
const connectedEither = mapStateToProps => predicate => (Left, Right) => { | |
const component = (props) => { | |
if(!predicate(props)) | |
{ | |
return <Left {...props} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const requireDir = require('require-dir') | |
const tasks = requireDir('./tasks', {recurse: true}) | |
let sequentialTaskChain = Promise.resolve(console.log('starting nightly tasks')) | |
Object.keys(tasks).map(key => { | |
sequentialTaskChain = sequentialTaskChain.then(() => { | |
return Promise.resolve(() => console.log('starting task', key)) | |
.then(tasks[key]) | |
.then(() => console.log('finished task', key)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withMaxAttemptsAndBackoff = ({ | |
waitTime = 100, | |
maxAttempts = 3, | |
}) => promise => (...args) => { | |
if (maxAttempts < 2) return promise(...args) | |
return promise(...args).catch(_ => | |
wait(waitTime).then(() => | |
withMaxAttemptsAndBackoff({ | |
waitTime: Math.min(waitTime * 2, 5000), |