Skip to content

Instantly share code, notes, and snippets.

View antoniocapelo's full-sized avatar

Capelo antoniocapelo

View GitHub Profile
@antoniocapelo
antoniocapelo / cover-background
Created July 17, 2014 22:35
Procedure to obtain the background cover effect whichs works on small or large screens
// Procedure to obtain the background cover effect whichs works on small or large screens
html {
background: url(url_to_img) no-repeat center center fixed;
background-size: cover;
height: 100%;
overflow: hidden;
}
body
@antoniocapelo
antoniocapelo / filtered-gif-cover-bg
Last active August 29, 2015 14:04
SCSS class for using a scaled and filtered gif as background
// Using a scaled and filtered gif as background
.background {
position: absolute;
top: 0;
left: 0;
width: 20%;
height: 20%;
z-index: -1;
background-image: url('http://37.media.tumblr.com/tumblr_lupg946u5S1qe0eclo1_r5_500.gif');
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@antoniocapelo
antoniocapelo / ClassExport
Last active August 29, 2015 14:04
Class creation and export on JavaScript
(function() {
var ClassName, root;
function ClassName (config) {
var privateProperty = 24;
this.publicProperty = 42;
privateMethod = function (foo) {
@antoniocapelo
antoniocapelo / gist:bfba67f96b4890e443e4
Created August 10, 2014 11:12
Detecting mobile device
/**
* Originally from http://www.abeautifulsite.net/detecting-mobile-devices-with-javascript/
**/
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
@antoniocapelo
antoniocapelo / createService
Last active August 29, 2015 14:06
Service Creation in AngularJS
var app = angular.module('capeloMod', []);
app.service('demoService', function() {
this.publicValue = 0;
var privateValue = 0;
var privateFn = function() {
return 1 + 2;
};
@antoniocapelo
antoniocapelo / createFactory
Created September 13, 2014 10:12
Factory creation in AngularJS
var app = angular.module('capeloMod', []);
//factory style, more involved but more sophisticated
app.factory('demoFactory', function() {
var publicValue = 0;
var privateValue = 0;
function apiFn() {
return this.publicValue++;
}
@antoniocapelo
antoniocapelo / createProvider
Created September 13, 2014 10:36
Provider Creation in AngularJS
var app = angular.module('capeloMod', []);
app.provider('demo', function() {
var cfg = 'Default';
this.setCfg = function(providedCfg) {
cfg = providedCfg;
};
this.$get = ['dependencyName', function(dependency) {
return new dependency(cfg);
@antoniocapelo
antoniocapelo / extendClass
Created September 13, 2014 10:51
Extending Classes in Javascript (Prototypal pattern)
function ClassName(name) {
this.name = name;
}
ClassName.prototype = {
constructor: ClassName,
greet: function () {
return 'My name is' + this.name;
}
};
@antoniocapelo
antoniocapelo / classPrototypePattern
Last active August 29, 2015 14:06
Class Creation - Prototype Pattern
(function(global) {
function OOPPattern(value) {
this.publicInstanceValue = value || 10;
var privateValue = 0;
var privatFn = function(argument) {
return 1 + 2;
}
this.api2NeedsPrivateValue = function(argument) {