Skip to content

Instantly share code, notes, and snippets.

View darekrossman's full-sized avatar

Darek Rossman darekrossman

View GitHub Profile
@darekrossman
darekrossman / array-fill.js
Last active August 11, 2017 13:32
Array Fill Range
Array.from(Array(100).keys())
@darekrossman
darekrossman / stateless-react-component-snippet.cson
Last active November 23, 2016 14:30
A React snippet for scaffolding out a stateless functional component, using Flow for prop types and custom HOCs for themability.
'Stateless React Component':
'prefix': 'srcc'
'body': '''
// @flow
import React, { PropTypes } from 'react';
import { compose } from 'recompose';
import { withStyles } from '_util/HOCs';
import { FlexBox } from '@madmobilenpm/mmui';
type Props = {
@darekrossman
darekrossman / jest-snapshot-test-snippet.cson
Last active November 18, 2016 21:09
A snippet for scaffolding out a basic snapshot test with Jest. It uses a custom HOC to provide our mocked context.
'Jest Snapshot Test':
'prefix': 'jst',
'body': '''
import React from 'react';
import renderer from 'react-test-renderer';
import { withAppContext } from '_util/test-utils';
import { default as Component } from '../$1';
const WrappedComponent = withAppContext(Component);
@darekrossman
darekrossman / calculateScore.js
Last active August 11, 2017 13:36
Bowling score string calculation
// Darek's `functional` bowling score algorithm!
function calculateScore(str) {
const rolls = str.split('');
return rolls.reduce((data, roll, index) => {
let rollScore = calcRoll(roll, data.prevRoll);
if (rolls.length - index > 2) {
if (/(\/|X)/.test(data.prevRoll))
rollScore *= 2;
if (/X/.test(data.prevRoll))
// Configurable variables
// ⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻
// Absolute height of body text, in pixels
$base-font-size: 16px !default;
// Absolute height of one line of type, in pixels
$base-line-height: 24px !default;
// The font unit to use when returning values in rhythm functions