Skip to content

Instantly share code, notes, and snippets.

The waitFor function wraps a component. This component will be rendered only once all promises in the promises iterable are resolved.

Options:

  • meanwhile: A react node which will be rendered until promises are resolved.
  • error: A react ndoe to be renderd in case any of the promises are rejected.

This is my first attempt at a higher-order component, inspired by Dan Abramov's post.

@burtyish
burtyish / regex collection.txt
Last active December 30, 2015 11:35
Some useful regexs for migrating cjsx files to ES6
// require -> import
([\w{},]+)[\s]?=[\s]?require[\s]?[(]?['"]([\w\/.-]+)['"][)]?
import $1 from '$2';
// module.exports -> export default
module.exports[\s]?=[\s]?([\w]+)
export default $1;
// @ -> this.
@
@burtyish
burtyish / New React component template (createClass)
Last active August 29, 2016 12:16
WebStorm template for new ES6 React component file. Converts hyphen-separated filenames to PascalCase class name.
#set( $lowerCaseName = "$NAME" )
#set( $newName = "" )
#foreach( $part in $NAME.split("-") )
#set( $newName = "$newName$part.substring(0,1).toUpperCase()$part.substring(1)")
#end
@burtyish
burtyish / An experiment in vector image (SVG).markdown
Last active August 29, 2015 14:21
An experiment in vector image (SVG)
@burtyish
burtyish / listify.coffee
Created September 23, 2014 07:45
A Handlebars.js helper that stringifies an array into readable form.
define [
'hbs/handlebars'
'underscore'
], (Handlebars, _) ->
"""
Breaks down an array into a comma-delimited list and 'and' before the last item.
Options:
total_count - If this is a number greater than the length of array, the difference will be added as 'and x others'.
first_item - this item will be inserted at the beginning of the array.
Examples:
@burtyish
burtyish / gist:31cfe7730e5825f702a1
Last active August 29, 2015 14:04
Chart.js configuration
chart_options: (data)->
min = Math.min 0,data...
max = Math.max data...
num_of_y_ticks = 5
scale_minmax_rounding_factor = if max > 10000 then 1000 else 500
y_scale_rounding_factor = if max > 10000 then 5000 else 1000
scale_max = scale_minmax_rounding_factor * Math.round(max/scale_minmax_rounding_factor)
scale_min = scale_minmax_rounding_factor * Math.round(min/scale_minmax_rounding_factor)
y_scale_step_size = (scale_max - scale_min) / (num_of_y_ticks)
y_scale_step_rounded = y_scale_rounding_factor * Math.round(y_scale_step_size / y_scale_rounding_factor)
@burtyish
burtyish / django-pageable-collection.coffee
Last active August 29, 2015 13:58
An extension of Backbone.PageableCollection to parse server responses created by Django Rest Framework.
define [
'jquery',
'underscore',
'backbone',
'backbone-pageable'
], ($, _, Backbone) ->
###
An extension of Backbone.PageableCollection to parse server responses created by Django Rest Framework.
The response structure is expected to match that provided by django-rest-framework's Pagination mechanism
@burtyish
burtyish / dabblet.css
Created January 27, 2014 15:39
zig-zag background (SO)
/**
* zig-zag background (SO)
* CSS Zigzag Border with a Textured Background
*/
background: linear-gradient(#BCED91 49%, transparent 49%),
linear-gradient(-45deg, white 33%, transparent 33%) 0 50%,
white linear-gradient(45deg, white 33%, #BCED91 33%) 0 50%;
background-repeat: repeat-x;
background-size: 1px 100%, 40px 40px, 40px 40px;
@burtyish
burtyish / dabblet.css
Created November 6, 2013 17:11
CSS Triangles
/**
* CSS Triangles
*/
.arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
@burtyish
burtyish / dabblet.css
Created November 6, 2013 17:11
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;