Skip to content

Instantly share code, notes, and snippets.

View xcambar's full-sized avatar

Xavier Cambar xcambar

View GitHub Profile
@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}
});
@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 / 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 / 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 / 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'
}
});
#install required packages
apt-get update
apt-get upgrade -y
apt-get install -y git curl build-essential libssl-dev libcurl4-openssl-dev nodejs
#install sqlite3 (optional)
apt-get install libsqlite3-dev sqlite3
#install postgres (optional)
sudo apt-get install postlibpq-dev
//
// This script shows how to add custom traits to a user
//
var hull = require('hull');
hull.conf({
appId: 'abcd',
orgUrl: 'https://demo.hullapp.io',
appSecret: '1234'
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"/Users/xav/code/karma-bro-proxyquireify/node_modules/proxyquireify/index.js":[function(require,module,exports){
'use strict';
function ProxyquireifyError(msg) {
this.name = 'ProxyquireifyError';
Error.captureStackTrace(this, ProxyquireifyError);
this.message = msg || 'An error occurred inside proxyquireify.';
}
function validateArguments(request, stubs) {
@xcambar
xcambar / grunt.site
Created October 1, 2014 08:41
NGinx configuration to proxy Grunt from a subdir
set $front_port "9000";
set $front_host "10.0.2.2";
location @proxy_to_front {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Protocol $scheme;
rewrite ^/app(.*) $1 break;
@xcambar
xcambar / node_nvm.sh
Last active August 29, 2015 14:07
Install Node 0.10.x with NVM
#!/usr/bin/env sh
#
# You can change the version by passing the "VERSION" environment variable
# eg, env VERSION=0.10 sh node_nvm.sh
#
: ${VERSION:="stable"}
echo