By Alex — for Pear
- Build AI apps with OpenAI, Claude, Gemini
- Generate images/videos for ads and socials at scale
- Use AI for analytics and charting
- Ship multi-agent automations for marketing & ops
import { map } from 'p-iteration'; | |
import _uniqBy from 'lodash/uniqBy'; | |
/* Array iteration with async/await */ | |
const getMultipleCategoryProducts = async productCategories => { | |
return map(productCategories, async category => { | |
const products = await getProductsByCategory(category); | |
return products; | |
}); | |
}; |
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { graphql } from 'react-relay'; | |
import { createRefetchContainer, QueryRenderer } from 'react-relay'; | |
import { identifyDataKey, hasNextPage, createDataArray } from '../../../utils/RelayHelpers'; | |
const ProductReviewsList = ({ data, loading, containerWidth, role }) => { | |
const renderRow = () => ( | |
<Flex flexColumn id="ReviewComments"> | |
<Box className="ProductReviews__divider"> |
import React, { PureComponent } from 'react' | |
const contextTypes = { | |
router: PropTypes.object.isRequired, | |
api: PropTypes.object.isRequired, | |
relay: PropTypes.shape({ | |
variables: PropTypes.shape({ | |
category: PropTypes.string.isRequired, | |
}).isRequired, | |
}).isRequired, |
import React, { PureComponent } from 'react' | |
const contextTypes = { | |
router: PropTypes.object.isRequired, | |
api: PropTypes.object.isRequired, | |
relay: PropTypes.shape({ | |
variables: PropTypes.shape({ | |
category: PropTypes.string.isRequired, | |
}).isRequired, | |
}).isRequired, |
import React from 'react' | |
class AsyncAwait extends React.Component { | |
constructor() { | |
super() | |
this.state = {} | |
} | |
async componentDidMount() { | |
const res = await this.context.api.fetch('/logout', { method: 'POST' }).then(() => { |
import React from 'react' | |
class AsyncAwait extends React.Component { | |
constructor() { | |
super() | |
this.state = {} | |
} | |
async componentDidMount() { | |
const res = await this.context.api.fetch('/logout', { method: 'POST' }).then(() => { |
import React, { PropTypes, Component } from 'react'; | |
import Relay from 'react-relay'; | |
import { Map } from 'immutable'; | |
import debounce from 'lodash/debounce'; | |
import AddToCartMutation from '../../mutations/AddToCartMutation'; | |
import RemoveFromCartMutation from '../../mutations/RemoveFromCartMutation'; | |
import CartEntry from '../cart/CartEntry'; | |
import InputQuantity from '../form/InputQuantity'; |
import React, { PropTypes } from 'react'; | |
import Relay from 'react-relay'; | |
import { Map } from 'immutable'; | |
import debounce from 'lodash/debounce'; | |
import AddToCartMutation from '../../mutations/AddToCartMutation'; | |
import RemoveFromCartMutation from '../../mutations/RemoveFromCartMutation'; | |
import CartEntry from '../cart/CartEntry'; | |
import InputQuantity from '../form/InputQuantity'; |
#' @param func = a site-by-species "functioning" matrix (cells are values of ecosystem function), | |
#' @param base = the row name or number of the baseline community; defaults to highest productivity community | |
#' @param standardize = TRUE, whether results are scaled by the maximum to units (-1, 1), | |
#' @param avg = TRUE, whether | |
#' @param avglvl = The top X% of sites that should be used as the baseline and then results averaged, default is top 90% | |
#' @return data.frame of Price components & summed effects | |
price = function(func, base = "best", standardize = TRUE, avg = FALSE, avglvl = 0.90) { | |
# Replace NAs with zeros |