Skip to content

Instantly share code, notes, and snippets.

class Tab extends React.Component {
static propTypes = {
active,
title,
children
};
render() {
return ...
}
@spacenick
spacenick / module.js
Created April 20, 2015 17:53
private functions
/// Everything defined here is defined in the scope of that module
/// so it wont pollute anything
var privateVar = "test";
var privateFn = function() {
// process stuff here
// we can use privateVar
}
@spacenick
spacenick / batch.md
Last active August 29, 2015 14:11
Save batches of objects

You need the async library for this function

var saveBatch = function(source, callback, limit) {
	limit = limit || 20;
    var nbSlices = Math.ceil(source.length / limit), i = 0;
    
    async.whilst(function() {
        return i < nbSlices;
 },
$stateProvider
.state('items', {
abstract: true,
url: "/items",
resolve :{
items: ['DataSource', function(DataSource) {
return DataSource.fetchItems();
}]
}
})
@spacenick
spacenick / gist:5397435
Last active December 16, 2015 07:18
Adding item to a relation on Parse
// You can do that in your Chrome Console
// Load the initial object, like an Attempt
var attempt = new Parse.Object("Attempt");
attempt.id = "myId";
attempt.fetch();
// Get the relation "handler" from the attempt object
var relation = attempt.relation("products");
@spacenick
spacenick / handlebars-live.md
Created December 12, 2012 14:10
Add live re-precompiling of handlebars templates with Yeoman/Grunt server every time you create/edit a template

In your project root:

npm install grunt-handlebars

Then edit your Gruntfile and add BEFORE the initConfig statement :

grunt.loadNpmTasks('grunt-handlebars');

Add to your Grunt config the following part