Skip to content

Instantly share code, notes, and snippets.

View jboulhous's full-sized avatar

Jamal Boulhous jboulhous

  • Morocco, Africa
View GitHub Profile
$.ajaxSetup({
beforeSend: function(xhr) {
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
}
});
@jboulhous
jboulhous / 1-ModelWithChangedEvents.js
Created October 25, 2012 12:33 — forked from mxriverlynn/1-ModelWithChangedEvents.js
simple backbone.js examples
var SomeModel = Backbone.Model.extend({});
someModel = new SomeModel();
someModel.bind("change", function(model, collection){
alert("You set some_attribute to " + model.get('some_attribute'));
});
someModel.set({some_attribute: "some value"});
@jboulhous
jboulhous / 1-ModelWithChangedEvents.js
Created October 29, 2012 15:51 — forked from mxriverlynn/1-ModelWithChangedEvents.js
simple backbone.js examples
var SomeModel = Backbone.Model.extend({});
someModel = new SomeModel();
someModel.bind("change", function(model, collection){
alert("You set some_attribute to " + model.get('some_attribute'));
});
someModel.set({some_attribute: "some value"});
@jboulhous
jboulhous / findkey.js
Created November 21, 2012 11:44 — forked from mxriverlynn/findkey.js
Find key by value, with underscore.js
function findKey(obj, value){
var key;
_.each(_.keys(obj), function(k){
var v = obj[k];
if (v === value){
key = k;
}
});
@jboulhous
jboulhous / gist:4203663
Created December 4, 2012 13:03 — forked from tmeasday/gist:4042603
Meteor "Join" - Javascript
Meteor.publish 'paths', (since) ->
pointHandles = {}
publishPath = (pathId) =>
pointHandles[pathId] = Points.find({pathId: pathId}).observe
added: (obj) =>
@set('points', obj._id, obj)
@flush()
# these two should never happen
changed: (obj) =>
@jboulhous
jboulhous / gist:4216074
Created December 5, 2012 14:51 — forked from incredimike/variousCountryListFormats.js
Country list as javascript array (alphabetical)
// This needs tidied up before production TODO
var country_list = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas"
,"Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia & Herzegovina","Botswana","Brazil","British Virgin Islands"
,"Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica"
,"Cote D Ivoire","Croatia","Cruise Ship","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea"
,"Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana"
,"Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bis
MyApp.module('MyApp.SomeBuilder', function(SomeBuilder, App, Backbone, Marionette, $, _){
'use strict';
// Controller
// ----------
SomeBuilder.Controller = Marionette.Controller.extend({
initialize: function(options){
this.navbarRegion = options.navbarRegion;
this.mainRegion = options.mainRegion;
class Backbone.Marionette.StackRegion extends Backbone.Marionette.Region
constructor: ->
super
@views = []
# Return the top view (currently visible)
peek: ->
@views[@views.length - 1] if @views.length
@jboulhous
jboulhous / router.js
Created January 28, 2013 11:52
Backbone.Router for Meteor
// Router for Pages
Session.set("currentPage", null);
var SimpleRouter = Backbone.Router.extend({
routes: {
"": "index",
"signup": "signup"
},
index: function () {
console.log("router : index")
Session.set("currentPage", "index");
@jboulhous
jboulhous / new_user.js
Created January 31, 2013 20:54
Create new Meteor user
Accounts.createUser(
{email:"[email protected]", password:"password"}
,function(e,r){
if(e){
console.error(e)
}else{
var me = Meteor.user();
console.log("created", me);
}