Skip to content

Instantly share code, notes, and snippets.

@b-ma
b-ma / test
Last active August 29, 2015 14:00
the meaning of life
var life = {
start: function() {
delete this.stop;
},
stop: function() {
console.log('arg...');
}
};
// v2
@b-ma
b-ma / underscore-mixins.js
Last active August 29, 2015 13:57
underscore mixins
_.mixin({
// from underscore's examples [http://underscorejs.org/#mixin](http://underscorejs.org/#mixin)
capitalize: function(string) {
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
},
ensureApi: function(obj, api) {},
/**
* add sep betwen 3 numbers:
@b-ma
b-ma / pubsub.js
Last active August 29, 2015 13:57
small pubsub - (maybe `call` api would be better finally...)
var cache = {};
var pubsub = {
publish: function(channel, args) {
if (!cache[channel]) {
return;
}
var stack = cache[channel];
@b-ma
b-ma / backbone-multirouter.js
Created March 4, 2014 20:41
allow to trigger multiple callback with 1 route using a route separator
Backbone.History.prototype.multiRouteSeparator = '|';
Backbone.History.prototype.loadUrl = function(fragment) {
fragment = this.fragment = this.getFragment(fragment);
// split the fragment according to the defined separator
var fragments = fragment.split(this.multiRouteSeparator);
// test handlers with each fragments
// the function doesn't return anything like the real one
// but it doesn't seems to create problems
@b-ma
b-ma / git-commands
Created November 30, 2013 12:38
common git commands
======================================================
GITHUB
======================================================
recap pour utlisation de git et github :
* * * * * * * *
* CREATION *
@b-ma
b-ma / index.html
Last active December 28, 2015 15:49
Strategy pattern
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Pattern Strategy</title>
</head>
<body>
<script src="./strategy.js"></script>
<script>