Skip to content

Instantly share code, notes, and snippets.

View alexcastillo's full-sized avatar
💭
Building an API to the brain

Alex Castillo alexcastillo

💭
Building an API to the brain
View GitHub Profile
@alexcastillo
alexcastillo / gist:a32d66bf844eafdd0f14
Created May 13, 2014 16:35
Javascript - Email validate function (regex based)
// Returns true or false wether or not the email passed as a parameter passes the test
function validateEmail (email) {
var emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return emailRegex.test(email);
}
@alexcastillo
alexcastillo / angular-hack.js
Last active March 3, 2016 02:10
Hacking AngularJS in oder to broadcast a custom event for directives
/**
* AngularJS hack - This way we can get and decorate all custom directives
* in order to broadcast a custom directive events: $directiveAdd
**/
// This is where all the custom directives will be stored
var $directives = [];
var originalModule = angular.module;
angular.module = function () {
var module = originalModule.apply(this, arguments);
var originalDirective = module.directive;
@alexcastillo
alexcastillo / angular-css-script.html
Last active August 29, 2015 14:13
AngularCSS - Snippet 1
<script src="libs/angular-css/angular-css.js"></script>
@alexcastillo
alexcastillo / angular-css-mdule.js
Created January 7, 2015 12:31
AngularCSS - Module
var myApp = angular.module('myApp', ['ngRoute','door3.css']);
@alexcastillo
alexcastillo / anglar-css-route1.js
Created January 7, 2015 12:31
AngularCSS - Route 1
$routeProvider
.when('/tickets', {
templateUrl: 'tickets/tickets.html',
controller: 'ticketsCtrl',
css: 'tickets/tickets.css'
});
@alexcastillo
alexcastillo / angular-css-directive1.js
Created January 7, 2015 12:32
AngularCSS - Directive 1
myApp.directive('itinerary', function () {
return {
restrict: 'E',
templateUrl: 'itinerary/itinerary.html',
css: 'itinerary/itinerary.css'
}
});
@alexcastillo
alexcastillo / angular-css-sqm.js
Created January 7, 2015 12:34
AngularCSS - SMQ
$routeProvider
.when('/tickets', {
templateUrl: 'tickets/tickets.html',
controller: 'ticketsCtrl',
css: [
{
href: 'tickets/tickets.mobile.css',
media: '(max-width: 480px)'
}, {
href: 'tickets/tickets.tablet.css',
@alexcastillo
alexcastillo / angular-css-persist.js
Created January 7, 2015 12:35
AngularCSS - Persist
$routeProvider
.when('/page1', {
templateUrl: 'page1/page1.html',
controller: 'page1Ctrl',
css: {
href: 'page1/page1.css',
persist: true
}
});
@alexcastillo
alexcastillo / angular-css-preload.js
Created January 7, 2015 12:36
AngularCSS - Preload
$routeProvider
.when('/page1', {
templateUrl: 'page1/page1.html',
controller: 'page1Ctrl',
css: {
href: 'page1/page1.css',
preload: true
}
});
@alexcastillo
alexcastillo / angular-css-bust-cache.js
Created January 7, 2015 12:36
AngularCSS - Bust Cache
$routeProvider
.when('/page1', {
templateUrl: 'page1/page1.html',
controller: 'page1Ctrl',
css: {
href: 'page1/page1.css',
bustCache: true
}
});