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 / facebook-my-pages.js
Created August 1, 2013 11:37
Get pages that i liked
getAccessToken = function(){
// get facebook access token
// scope : user_likes
};
var url = 'https://graph.facebook.com/me?fields=likes.fields(global_brand_children)&access_token=';
url += getAccessToken();
$.get(url,function(resp,status,xhr){
var pages = resp.likes.data;
@jboulhous
jboulhous / log.js
Created July 31, 2013 12:34
a cool loggin function that is cool
var log = function(first){
return function(){
var args = Array.prototype.slice.apply(arguments);
console.log(first,args);
};
};
/*
Usage
@jboulhous
jboulhous / fevents.js
Created July 18, 2013 13:41
Create and Delete Facebook Events in a Meteor.js Application
if (Meteor.isClient){
function throwError (param) {
throw new Error('Need a '+ param + 'for the event to be created')
}
createEvent = function(options,cb){
var name = options && options.name || throwError('name');
var start = options && options.start_time || throwError('start_time');
var access_token = options && options.access_token || throwError('access_token');
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
;(function(geolocation){
if (geolocation) return;
var cache;
successHandler = function(position){
// position
console.log(position);
};
errorHandler = function(error){
// PositionError
console.log(error);
};
@jboulhous
jboulhous / push.md
Created July 16, 2013 11:37
Push to github from cloud9

Add a git remote in the Cloud9 console. Should look like this (replace the git url with your repo url):

git remote add origin [email protected]:C9Support/testPush.git 

Add files and commit them:

git add . 
git commit -m "First commit"

Push to github:

@jboulhous
jboulhous / quickUser.js
Created July 15, 2013 23:49
developement helper to create user
quickUser = function(name){
return {
username : name,
email : name+'@home.com',
password : 'initjkly',
profile : { name : name }
}
}
// https://github.com/eventray/backbone.synctracker
(function() {
'use strict';
//Save a reference to the global object (`window` in the browser, `exports`
// on the server).
var root = this;
var ajaxSync = Backbone.sync;
@jboulhous
jboulhous / slugify.js
Created May 20, 2013 09:17 — forked from mathewbyrne/slugify.js
Make url slug
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
/**
* What happens here? An anonymous function is created with a function body consisting only of a multi-line comment.
* The comment itself is the very text you want to embed in your application.
* The function is then serialized to a string using toString().
* Interestingly, the call preserves the function signature along with the function body and the comments within.
* Last, a regular expression is run over the serialized form of the function to extract the comment hidden inside.
* The end result assigned to the html variable contains the HTML content within the comment.
*/
var html = (function () {/*