Skip to content

Instantly share code, notes, and snippets.

View aganglada's full-sized avatar
👨‍💻

Alejandro Garcia Anglada aganglada

👨‍💻
View GitHub Profile
@aganglada
aganglada / Prueba
Created January 30, 2012 10:48
Gist de prueba
Esto es un gist de prueba
@aganglada
aganglada / Angular+Webpack
Last active August 29, 2015 14:23
Angular + Webpack
Web components are arguably the Way Of The Future, they provide reusability of code and encapsulation of logic with the view.
Angular allows us to create native looking web components with directives, but also allows standalone controllers to be made.
Doing things this way helps future-proof our app by forcing us to structure our app like we were using native web components already.
@aganglada
aganglada / casper2php.js
Created August 10, 2015 21:29
Execute php script from casperjs
var casp = require('casper').create({
verbose: true,
logLevel: 'debug'
});
casp.start().then(function() {
var finished = false;
var cp = require('child_process');
cp.execFile('/usr/bin/php','test.php', {},function(_,stdout,stderr){
console.log(stdout);
@aganglada
aganglada / script-cache.js
Created February 24, 2017 11:00
Script Cache Promise based
let counter = 0;
let scriptMap = new Map();
export const ScriptCache = (function(global) {
return function ScriptCache (scripts) {
const Cache = {};
Cache._onLoad = function(key) {
return (cb) => {
let stored = scriptMap.get(key);
@aganglada
aganglada / intersection-observer.js
Last active September 21, 2017 19:14
Intersection Observer
if (!this.props.observeOnScroll) {
return false
}
this.observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
const { isIntersecting, intersectionRatio } = entry
if (isIntersecting === true || intersectionRatio > 0) {
this.createImage()
const img = new Image()
img.src = this.props.src
img.onload = this.onLoadImage
img.onerror = this.onLoadImageError
loadPolyfills()
.then(() => /* Render React application now that your Polyfills are ready */)
/**
* Do feature detection, to figure out which polyfills needs to be imported.
**/
function loadPolyfills() {
const polyfills = []
if (!supportsIntersectionObserver()) {