Skip to content

Instantly share code, notes, and snippets.

View marioblas's full-sized avatar
🏠
Working from home

Mario Blas Gil Cárdenes marioblas

🏠
Working from home
View GitHub Profile
@marioblas
marioblas / add-attributes.js
Last active December 21, 2017 17:41
Underscore.js - Add attributes to each object of an array
/**
* Add attributes to each object of an array.
*
* @param {array} foo - Array of objects where we will add the attibutes
* @param {function} iterator
*/
_.each(foo, function(element, index) {
_.extend(element, {field1: index}, {field2: 'bar', field3: 'baz'});
});
@marioblas
marioblas / insert-reactive-content.js
Last active August 29, 2015 13:58
Meteor 0.8.0 (blaze) - Inserting some reactive Meteor UI content into an existing document
/**
* Inserting some reactive Meteor UI content into an existing document.
*
* UI.render instantiates a template and UI.insert adds it as a child of some element in the DOM.
* UI.renderWithData is like UI.render which also sets the data context.
*/
UI.insert(UI.render(Template.foo), document.body);
UI.insert(UI.renderWithData(Template.foo, {bar: "baz"}), document.body);
@marioblas
marioblas / vertical-align.css
Last active April 17, 2016 17:45
Twitter Bootstrap - Align vertically a column
/* Align vertically a column */
.v-align {
float: none;
display: inline-block;
vertical-align: middle;
}
@marioblas
marioblas / checkbox.js
Created February 12, 2014 23:24
jQuery - Know if all checkboxes are selected
/**
* Know if all checkboxes are selected.
* Note: You can add the same class for each checkbox instead of use :checkbox selector
*/
$(':checkbox').on('change', function() {
if ( $(':checkbox:checked').length == $(':checkbox').length ) {
// Do something
}
});