Skip to content

Instantly share code, notes, and snippets.

View xcambar's full-sized avatar

Xavier Cambar xcambar

View GitHub Profile
@xcambar
xcambar / hull-restify.js
Created March 3, 2014 17:14
Example of Hull API with node-restify
var restify = require('restify');
var client = restify.createJsonClient({
url: 'https://YOUR_ORG_NAMESPACE.hullapp.io',
headers: {
'Hull-App-Id': 'YOUR_APP_ID',
'Hull-Access-Token': 'YOUR_APP_SECRET'
}
});
@xcambar
xcambar / multi-lock.coffee
Last active December 30, 2015 11:19
A simple lock for when you ned to perform an action after a set of unrelated conditions are met
createLock = (locks, openDoorFn)->
_locks = [].concat locks
(lock)->
index = _locks.indexOf lock
openDoorFn() if !!~index and _locks.splice(index, 1).length and !_locks.length
unlock = createLock ['init', 'require'], -> alert("Unlocked")
unlock('abc') # ignored
unlock('bcd') # ignored
@xcambar
xcambar / HTML5 Skeleton template.html
Last active December 28, 2015 21:39 — forked from rtuin/HTML5 Skeleton template.html
HTML minimal template with Hull comments
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<!-- Insert you hull.io dashboard snippet here -->
</head>
<body></body>
</html>
@xcambar
xcambar / demo.hull.api.js
Last active December 23, 2015 23:19
hull.api.js - Lightning fast snippet
Hull.init({
appId: "XYZ",
orgUrl: "abc"
}).then(function (obj) {
console.log('Hull.js is initialized, you can starts doing API calls');
// You can do API calls whether from the obj parameter or from the global object Hull (see below)
}, function (err) {
console.error('Ooops, something went wrong:', err);
});
@xcambar
xcambar / demo_friends.js
Created July 29, 2013 21:22
Use Hull to retrieve friends from your networks
Hull.data.api({
provider: 'facebook',
path: 'me/friends'
}).then(function (data) {
console.log('Data from Facebook:', data); //should be like {data: Array, paging: Object}
});
<?php
require 'vendor/autoload.php';
$hull = new Hull_Client(array( 'hull' => array(
'host' => 'YOUR_ORG_URL',
'appId' => 'YOUR_APP_ID',
'appSecret' => 'YOUR_APP_SECRET'
)));
$app = $hull->get('app');
var_dump($app);
@xcambar
xcambar / gh_pages.zsh
Last active December 15, 2015 09:09
ZSH Function to deploy to Github Pages
#
# Usage:
# ghp BUILD_DIR GIT_REPO_URL
#
function ghp () {
cd $0
git init
git add -A
git remote add origin $1
git commit -m "Generated at $(date)"
@xcambar
xcambar / clouseau-ex.js
Created March 14, 2013 17:43
An example for Clouseau
var clouseau = require('clouseau-js');
function alertCheck(page) {
var dfd = this; // `this` is a deferred! \o/
page.onAlert = function (txt) {
if (txt !== 'MY EXPECTED MESSAGE') {
return dfd.reject(new Error("Unexpected message: " + txt));
}
return dfd.resolve(page);
};
@xcambar
xcambar / LICENSE
Last active November 20, 2015 12:57
Authenticated routing using AngularJS
Copyright (c) 2015 - Xavier Cambar <@ xcambar_gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@xcambar
xcambar / 3rdparty-to-module
Created September 27, 2012 10:40
Turning a 3rd party ES5-lib to an ES6 module
Module ModernizrLoader {
import * from "./modernizr.min.js"
export Modernizr
}