Skip to content

Instantly share code, notes, and snippets.

export function fetchTokenAndPostCreditCard(card) {
return (dispatch) => {
dispatch(requestCardToken())
return new Promise(
function(resolve, reject) {
return iiTokenization.resolveToken({
env: 'dev2',
dev: true,
accessToken: 'a696c977-b32c-4751-9916-33e6329a921b',
data: {
* As a salesperson I want to add clients to the application so I contact them and keep track of our interactions
* As a salesperson I want to edit client data so that I can keep the info I have on them up to date
* As a salesperson I want to add information about an interaction with a client so that it's logged and can be shared later
* As a salesperson I want the ability to maintain multiple points of contact for a client (so...)
*
import * as ProgramApi from '../models/ProgramApi'
import standardAction from '../util/standardAction'
export const BEGIN_INDEX = 'PROGRAMS:BEGIN_INDEX'
export const RECEIVE_INDEX = 'PROGRAMS:RECEIVE_INDEX'
export function indexRequest(filterOptions) {
return (dispatch) => {
dispatch(standardAction(BEGIN_INDEX))}
return ProgramApi.index(filterOptions)
export const searchIds = (query, options = {}) => {
return client
.search({index, ...options, body: query})
.then((results) => {
const {hits} = results.hits
return hits.map((result) => result._id)
})
}
import React, {Component, PropTypes} from 'react'
import textWithPlaceholder from '../util/textWithPlaceholder'
class DataCol extends Component {
static propTypes = {
label: PropTypes.string.isRequired,
text: PropTypes.string,
className: PropTypes.string,
}
class Author < ActiveRecord::Base
has_many :books
# this is bad
def scifi_books
books.by_category('scifi')
end
# this is better (with caveats?). The caveat is that as the number of associated records increases
# this will get slower, and may get to a point where it's best to fall back to a more complex SQL
Environment.config do
required :ENV_KEY
warn :ENV_KEY_2
end
class ViewModel {
constructor(subject) {
this.subject = subject
}
}
class ExampleViewModel extends ViewModel {
fooPlus(num) {
return subject.foo + num
}
_isEditThrow() {
const { scoreFrame } = this.props
const isTenth = scoreFrame.position === 10
if (!scoreFrame) { return 1 }
return (isTenth && scoreFrame.throw2) ? 3 : 2
}
class MyCoolButton extends Component {
_onPressButton() {
this.props.beforeButtonAction()
console.log("this button doesn't do anything useful")
}
render() {
return <Button onPress={this._onPressButton.bind(this)}>
}
}