Skip to content

Instantly share code, notes, and snippets.

Nicolas Kermarc spacenick

Block or report user

Report or block spacenick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View accordion_react.js
class Tab extends React.Component {
static propTypes = {
active,
title,
children
};
render() {
return ...
}
@spacenick
spacenick / module.js
Created Apr 20, 2015
private functions
View module.js
/// 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 Aug 29, 2015
Save batches of objects
View batch.md

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;
    },
View states.js
$stateProvider
.state('items', {
abstract: true,
url: "/items",
resolve :{
items: ['DataSource', function(DataSource) {
return DataSource.fetchItems();
}]
}
})
@spacenick
spacenick / gist:5397435
Last active Dec 16, 2015
Adding item to a relation on Parse
View gist:5397435
// 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 Dec 12, 2012
Add live re-precompiling of handlebars templates with Yeoman/Grunt server every time you create/edit a template
View handlebars-live.md

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

You can’t perform that action at this time.