Skip to content

Instantly share code, notes, and snippets.

View filippomangione's full-sized avatar

Filippo Mangione filippomangione

  • Boolean Careers
  • Milano
View GitHub Profile
@esamattis
esamattis / asevents.js
Last active October 22, 2021 20:41
Use listenTo/stopListening from Backbone.js with any DOM element
/**
* Use listenTo/stopListening from Backbone.js with any DOM element
*
* Example:
*
* view.listenTo(asEvents(window), "resize", handler);
*
* and the listener will be remove automatically on view.remove() or
* view.stoplistening()
*
@funkjedi
funkjedi / marionette.handlebars.js
Last active April 5, 2024 14:29
Integrates Handlebars with Marionette. First attempts to load pre-compiled templates, then by selector, and finally via XHR.
/**
Usage: Just include this script after Marionette and Handlebars loading
IF you use require.js add script to shim and describe it in the requirements
*/
(function(Handlebars, Marionette) {
Marionette.Handlebars = {
path: 'templates/',
extension: '.handlebars'
};
@fnakstad
fnakstad / gist:5383750
Created April 14, 2013 18:43
Attaches a function called "seed" to Mongoose models, which basically wraps the create function, but returns a promise. This way seeding can be done through a promise chain.
var mongoose = require('mongoose');
mongoose.Model.seed = function(entities) {
var promise = new mongoose.Promise;
this.create(entities, function(err) {
if(err) { promise.reject(err); }
else { promise.resolve(); }
});
return promise;
};
@there4
there4 / .jshintrc
Last active March 20, 2020 13:46
JSHint Configuration, with requirejs
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
// create pub-sub functionality
Backbone.pubSub = _.extend({}, Backbone.Events);
// view one needs to trigger an event in view2
View1 = Backbone.View.extend({
triggerView2Event : function() {
Backbone.pubSub.trigger('view2event', { 'some' : 'data' } );
})
@dstorey
dstorey / dabblet.css
Created July 3, 2012 06:53
set the size of the boxes and any decoration
.slider {
/* set initial width */
width: 520px;
/* hide the content that overflows (to allow second box to show through) */
overflow: hidden;
display: inline-block;
/* skew container so that it has angled edge, and set up transition */
transform: skewX(-20deg);
@dharFr
dharFr / jquery.observer.js
Created February 28, 2012 00:39
jQuery based observer pattern
;(function($) {
/*
* jQuery Observer pattern
* inspired by @addyosmani 's code
* see: http://addyosmani.com/resources/essentialjsdesignpatterns/book/#highlighter_506612
*/
var topics = [];
function getTopic(id) {
var callbacks;
topic = id && topics[id];
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat