Skip to content

Instantly share code, notes, and snippets.

View gonzaloruizdevilla's full-sized avatar

Gonzalo Ruiz de Villa gonzaloruizdevilla

  • GFT
  • Madrid, Spain
View GitHub Profile
@gonzaloruizdevilla
gonzaloruizdevilla / REPL-javascript.js
Created May 2, 2012 09:48
REPL y estilo coma primero en javascript
//El REPL de node.js no interpreta correctamente esto:
var a = 1
, b = 2
, c = 3;
//En cambio esto funciona bien:
var a = 1,
@gonzaloruizdevilla
gonzaloruizdevilla / gist:3780545
Created September 25, 2012 08:03
AngularJs y detección de conexión para cambiar sistema de almacenamiento
angular.module('myApp').run(function($rootScope) {
window.addEventListener("online", function () {
$rootScope.$broadcast('onlineChanged', true);
}, true);
window.addEventListener("offline", function () {
$rootScope.$broadcast('onlineChanged', false);
}, true);
});
@gonzaloruizdevilla
gonzaloruizdevilla / gist:4168405
Created November 29, 2012 11:34 — forked from Mithrandir0x/gist:3639232
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
var http = require('http'), httpProxy = require('http-proxy');
/**
* HTTP authentication module.
*/
var auth = require('http-auth');
/**
* Requesting new authentication instance.
*/
var moduleA = function () {
return {
data: dataArrayObject,
init: function () {
this.addTable();
this.addEvents();
},
var moduleD = function () {
return {
data: dataArray,
init: function () {
this.addTable();
this.addEvents();
},
moduleG = function () {};
moduleG.prototype.data = dataArray;
moduleG.prototype.init = function () {
this.addTable();
this.addEvents();
};
moduleG.prototype.addTable = function () {
var template = _.template($('#template').text());
var html = template({'data' : this.data});
// Prototypal pattern
Klass1 = function () {}
Klass1.prototype.foo = function () {
log('foo');
}
Klass1.prototype.bar = function () {
log('bar');
}
// Module pattern

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

// Directives
(function (angular) {
'use strict';
var filtroVisor = "filtrovisor";
function FilterVisor($timeout, $http, $q) {
return {
restrict: 'A',
require: '?ngModel',