Skip to content

Instantly share code, notes, and snippets.

View xcambar's full-sized avatar

Xavier Cambar xcambar

View GitHub Profile
@xcambar
xcambar / string_prototype_extension_fail.js
Created October 18, 2011 08:44
String prototype extension fail!
/**
* Comparing a String object and a simple string
**/
var myStringSimple = 'abcd';
console.log(myStringSimple instanceof String); // false
console.log(typeof(myStringSimple)); // 'string'
var myStringObject = new String('abcd');
console.log(myStringSimple instanceof String); // true
@xcambar
xcambar / esharmony-export-confilcts
Created March 7, 2012 00:34
ECMAScript Harmony - conflicting states in grammar
Program ::= ProgramElement*
ProgramElement ::= Statement
| VariableDeclaration
| FunctionDeclaration
| ImportDeclaration
| ExportDeclaration
| ModuleDeclaration
ModuleSpecifier ::= StringLiteral | Path
ModuleDeclaration ::= "module" Id "at" String ";"
@xcambar
xcambar / gist:3792865
Created September 27, 2012 08:22
Module Pattern
var AdamsModule = (function (foo, bar) {
var theAnswer = 42;
var questionFromAnswer = function () { /** ? **/ };
return {
getTheAnswer : function () { return theAnswer; },
computeQuestion : function () {
questionFromAnswer(this.getTheAnswer());
}
}
})(foo, bar)
@xcambar
xcambar / gist:3792881
Created September 27, 2012 08:26
Object Literal
var i = {
a : function () { },
BASE_VALUE: 42
}
@xcambar
xcambar / module1
Created September 27, 2012 09:43
basic Harmony module
Module dynamicList {
import xhr from '/dataSources.js'; // dataSources is another module
import template at '/tpls/list.js';
var classNames = ['dynamic', 'vertical'];
var refreshInterval = 300000; //ms
var run = function (rootElt, params) {
return setInterval(function () {
xhr.get('/list', params, function (data) {
template.compile(data, rootElt, {classes: classNames});
@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
}
@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 / 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 / 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)"
<?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);