This file contains 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
#models.py | |
class Task(models.Model): | |
title = models.CharField(max_length=255) | |
description = models.TextField() | |
def __unicode__(self): | |
return self.title | |
This file contains 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, {Component, PropTypes} from 'react'; | |
const DEFAULT_STROKE_WIDTH = 0.15; | |
const DEFAULT_STROKE_COLOR = '#e1e1e1'; | |
/** | |
* SVGPath is an svg <path> element with utitlities | |
* | |
* @param {object[]} points - Array of Point objects - {x, y} - to plot this path | |
* @param {string} color - stroke color of path |
This file contains 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
/** | |
* @function parseStyles | |
* Parses a string of inline styles into a javascript object with casing for react | |
* | |
* @param {string} styles | |
* @returns {Object} | |
*/ | |
const parseStyles = styles => styles | |
.split(';') | |
.filter(style => style.split(':')[0] && style.split(':')[1]) |
This file contains 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
from django import template | |
from django.contrib.staticfiles.finders import find as find_static_file | |
from django.conf import settings | |
register = template.Library() | |
@register.simple_tag | |
def encode_static(path, encoding='base64', file_type='image'): | |
""" |
This file contains 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, {Component, PropTypes} from 'react'; | |
/** | |
* createNthChild is a factory for NthChild components. | |
* | |
* Can set conditional styling meant to simulate css's nth-child pseudo selector | |
* | |
* @param {object} [options] - styles options to pass into the icon panel | |
* @param {function} [styleFirst] - if isFirst, invoke styleLast(options.styles) |
This file contains 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
/** | |
* Immutable move item | |
*/ | |
const move = (arr, from, to) => { | |
const clone = [...arr]; | |
Array.prototype.splice.call(clone, to, 0, | |
Array.prototype.splice.call(clone, from, 1)[0] | |
); | |
return clone; | |
}; |
This file contains 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 reduce = require("./reduce"); | |
/** | |
* Performs right-to-left function composition. The rightmost function may have | |
* any arity; the remaining functions must be unary. | |
* compose(f, g)(x) >> f(g(x)) | |
* | |
* @example | |
* const doubleNegative = compose(x => x * -1, x => x * 2); | |
* doubleNegative(5); // -10 |
This file contains 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
// this file should actually be in reducers/index.js | |
import {combineReducers} from 'redux'; | |
const rootReducer = combineReducers( | |
allReducers(require.context('.', false, /^\.\/(?!index)\w+$/)) | |
); | |
export default rootReducer; |
This file contains 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
/** | |
* Turns generators into async demons | |
* | |
* Within the generator function, any "yield" operator becomes enhanced with async powers | |
* allowing them to yield promises. | |
* | |
* @example | |
* spawn(function *() { | |
* const data = yield fetch('/foo.json'); // will be resolved and assigned to "data" var | |
* console.log(data); // write like its sync but its acually async ;) |
This file contains 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 * as R from 'ramda'; | |
const resolveModuleFromLocation = R.curry((location, next) => { | |
try { | |
return require.resolve(location) && require(location); | |
} catch (err) { | |
if (next && err && err.code === 'MODULE_NOT_FOUND') { | |
return next(); | |
} | |
} |
NewerOlder