Skip to content

Instantly share code, notes, and snippets.

View jboulhous's full-sized avatar

Jamal Boulhous jboulhous

  • Morocco, Africa
View GitHub Profile
@jboulhous
jboulhous / blog_routes.php
Created May 15, 2013 13:51
blog routes using Codeigniter
<?php
$route['page/(:num)'] = 'blog/index/$1';
$route['blog/page/(:num)'] = 'blog/index/$1';
$route['(:num)/(:num)/(:num)/(:any)'] = 'blog/post/$1/$2/$3/$4';
$route['post/(:any)'] = 'blog/post/$1';
$route['archive/(:any)'] = 'blog/archive/$1';
$route['category/(:any)'] = 'blog/category/$1';
$route['tags/(:any)'] = 'blog/tags/$1';
$route['search'] = 'blog/search';
@jboulhous
jboulhous / models.js
Created April 26, 2013 01:39
Meteor and Backbone Model and Collection Simply
// BackboneModel
// -------------------
// it's a Backbone.Model that will be able toe synch with a Meteor.Collection.
// as simple as it could be
var Model = Meteor.Backbone.Model = Backbone.Model.extend({
idAttribute : '_id',
_insert : function ( child , options ) {
@jboulhous
jboulhous / functional_helpers.js
Created April 8, 2013 10:44
a try to get some functional helpers from allong.es most of this code is copied from from https://github.com/raganwald/allong.es
// a try to get some functional helpers from allong.es
// most of this code is copied from from https://github.com/raganwald/allong.es
// helpers
var slice = Array.prototype.slice;
// to_function
function to_function (str) {
var expr, leftSection, params, rightSection, sections, v, vars, _i, _len;
params = [];
@jboulhous
jboulhous / Meteor-Sessioned-Object
Created April 1, 2013 11:38
Sessioned object, could be instanciated to handle some Session vars, this is not realy a great piece of code, but if you don't realy like the Session.get/.set you can still use it this way :p
Sessioned = function(prefix){
this.prefix = prefix || Random.hexString(16)
}
_.extend(Sessioned.prototype,{
get : function(key){
key = this.prefix + '-' + key
return Session.get(key)
},
set : function(key,value){
/*
HTTP status code messages
*/
function getStatusCodeMsg (code) {
var msg = false;
switch (code) {
@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);
}
@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");
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
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;