Skip to content

Instantly share code, notes, and snippets.

View afuggini's full-sized avatar

Ariel Fuggini afuggini

View GitHub Profile
// #1 ES6: if passing one argument you don't need to include parenthesis around parameter.
var kitty = name => name;
// same as ES5:
var kitty = function(name) {
return name;
};
// #2 ES6: no parameters example.
var add = () => 3 + 2;
var defaults = {
number: 1,
bool: true,
magic: 'real',
animal: 'whale',
croutons: 'delicious'
};
var options = {
number: 2,
@afuggini
afuggini / extend.js
Created September 12, 2016 20:11
Vanilla object extend function (UnderscoreJS)
var extend = function() {
var extended = {};
for(key in arguments) {
var argument = arguments[key];
for (prop in argument) {
if (Object.prototype.hasOwnProperty.call(argument, prop)) {
extended[prop] = argument[prop];
}
}
@afuggini
afuggini / nginx.config
Created October 5, 2016 16:13 — forked from jakemmarsh/nginx.config
Modify nginx proxy settings in Elastic Beanstalk options
files:
"/tmp/proxy.conf":
mode: "000644"
owner: root
group: root
content: |
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
@afuggini
afuggini / install
Last active May 13, 2017 02:47
Server Deploy
#!/bin/sh
# Install GIT
sudo yum install git-all
# Install NODE
yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
yum install -y nodejs
@afuggini
afuggini / defineProperty.js
Last active October 29, 2021 17:29
Object.defineProperty polyfill
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
*/
// vim: ts=4 sts=4 sw=4 expandtab
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
;
@afuggini
afuggini / wrapper.js
Created January 22, 2018 17:38
Sample VPAID Video player Interface Code
// This class is meant to be part of the video player that interacts with the Ad.
// It takes the VPAID creative as a parameter in its contructor.
var VPAIDWrapper = function (VPAIDCreative) {
this._creative = VPAIDCreative
if (!this.checkVPAIDInterface(VPAIDCreative)) {
//The VPAIDCreative doesn't conform to the VPAID spec
console.error('VPAIDCreative doesn\'t conform to the VPAID spec')
return
}
this.setCallbacksForCreative()
@afuggini
afuggini / cookies.js
Created February 2, 2018 21:26 — forked from CrocoDillon/cookies.js
Export your awesome module using AMD, CommonJS, Node.js or just as global.
/*
* Inspiration (well… copy pasting more or less) from:
* https://github.com/ScottHamper/Cookies/blob/0.3.1/src/cookies.js#L127-L140
*
* Thanks Scott!
*/
(function (global) {
'use strict';
var MyModule = function () {
@afuggini
afuggini / background.js
Created February 11, 2018 15:29 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@afuggini
afuggini / vpaid.js
Last active April 30, 2018 02:10
VPAID container class template
class VPAIDContainer {
constructor () {
// The slot is the div element on the main page that the ad is supposed to occupy
this._slot = null
// The video slot is the video object that the creative can use to render and video element it might have.
this._videoSlot = null
}
initAd (width, height, viewMode, desiredBitrate, creativeData, environmentVars) {
// slot and videoSlot are passed as part of the environmentVars
this._slot = environmentVars.slot