Skip to content

Instantly share code, notes, and snippets.

View rlucha's full-sized avatar

Rob Lucha rlucha

View GitHub Profile
/**
* AngularJS service to validate spanish document id.
* Returns the type of document and checks its validity.
*
* Usage:
* angular
* .module('myApp', [ 'validate-spanish-id' ])
* .controller('myController', function(ValidateSpanishID){
* ValidateSpanishID.validate( str );
* })
/**
* AngularJS service to validate spanish document id.
* Returns the type of document and checks its validity.
*
* Usage:
* angular
* .module('myApp', [ 'validate-spanish-id' ])
* .controller('myController', function(ValidateSpanishID){
* ValidateSpanishID.validate( str );
* })
@rlucha
rlucha / gist:6ddba81e6814eb58be71
Created January 30, 2015 16:12
Intercom init & event tracking
function UserTrackingSrv(ids) {
var self = this;
var appIDs = ids;
var userID;
var userLogged = false;
var ic;
this.init = function() {
if (appIDs.analyticsID !== undefined) {
@rlucha
rlucha / console_patch.js
Created December 9, 2015 08:29 — forked from FGRibreau/console_patch.js
Add timestamp information to the JavaScript console
/**
* Patch the console methods in order to provide timestamp information
*
* Usage:
* > console.log('ok')
* 2012-09-06T11:52:56.769Z ok true
*
* Note:
* The patch will only be applied with the first call.
*
@rlucha
rlucha / gist:20216160a5ade004793e
Created March 6, 2016 12:32
Medium - JSPM 0.17 - 01
package: {
// config here...
// etc.
}
function* naturalNumbers() {
let i = 0;
while(true) {
yield i++;
}
}
function* fib(a, b) {
let c = 0
yield a
yield b
while (true) {
c = a + b
a = b
b = c
yield c
}
function take(n, iterable) {
let result = [], i = 0
while (i < n) {
result.push(iterable.next().value)
i++
}
return result
}
function takeWhile(conditionFn, iterable) {
let result = []
let value = take(1, iterable)
while (conditionFn(value)) {
result = result.concat(value)
value = take(1, iterable)
}
return result
}
function* fib(a, b) {
let c = 0
yield a
yield b
while (true) {
c = a + b
a = b
b = c
yield c