Skip to content

Instantly share code, notes, and snippets.

View dtothefp's full-sized avatar

David Fox-Powell dtothefp

  • Flexport
  • United States
View GitHub Profile
export default [
{title: 'red', message: 'I\'m red', color: 'red'},
{title: 'blue', message: 'I\'m blue', color: 'blue'},
{title: 'green', message: 'I\'m green', color: 'green'}
]
import {get as getFormData} from './form-data.js';
class FormComp extends Component {
constructor(props) {
super(props);
this.inputs = getFormDate({omit: ['zipcode']}).map((inputData, i) => <Input {...inputData} key={`form_comp_${i}`} required />);
}
render() {
return (
@provideReactor(provideContextProps)
class Wrapper extends Component {
static propTypes = {
children: PropTypes.array.isRequired
};
render() {
<div>
{this.props.children}
</div>
/*
* Objects
*/
const props = {
1: 1,
2: 2,
3: 3,
4: 4
}
const {a,b, ...rest} = props //a = 1, b = 2, rest = {3: 3, 4: 4}
//colors
/^(?:#?[a-f\d]+|[a-s]{1,4}\s?\([\d%\s,.]+\))$/i
'hsla(0, 10%, 50%, 0.5)'
'#000000000'
'#11111'
'argb(1,1,1)'
'hsl (20,0%, 50%)'
'hsl(20, 20%, 20%)'
'#6F6F6F'
import request from 'superagent';
import cheerio from 'cheerio';
import vo from 'vo';
import {readFile} from 'fs';
/**
* An example generator
*/
function *gen(init) {
//confusing because what is stored in `first` variables is not what is returned from
const fromSpawn = spawn(function *() {
const someVal = yield new Promise((res, rej) => {
setTimeout(res.bind(null, 'whatevs!!!'), 1000);
});
bloooBlaahhh
});
fromSpawn.then((data) => {
console.log('Data from spawn', data);
const fromSpawn = spawn(function *() {
let rejValFirst, rejValSecond, resValLast;
try {
rejValFirst = yield new Promise((res, rej) => {
setTimeout(rej.bind(null, 'blaaa...first rejected!!!'), 1000);
});
} catch (err) {
console.error('Inside spawn error', err);
function spawn(gen) {
const it = gen();
function _co(method, arg) {
let res;
try {
console.log('***TRY***', method, arg);
res = it[method](arg);
} catch(err) {