Skip to content

Instantly share code, notes, and snippets.

View albertoarena's full-sized avatar
🎯
Focusing

Alberto Arena albertoarena

🎯
Focusing
View GitHub Profile
@albertoarena
albertoarena / FileStorageFactory.php
Last active November 11, 2020 12:37
Using the Factory method pattern to have different file storage mechanisms.
<?php
/**
* Class FileStorageFactory
* A factory class that instantiates the appropriate FileStorage engine
*/
class MyProject_Service_FileStorageFactory
{
/**
* Available file storage mechanisms
@albertoarena
albertoarena / getterSetter.js
Last active August 29, 2015 14:14
Getter/Setter RequireJS module
define([], function () {
return function(initValue, callback) {
var val = initValue;
if (typeof callback != 'function') {
callback = null;
}
return function (v) {
if (v !== undefined) {
val = v;
@albertoarena
albertoarena / person.js
Last active August 29, 2015 14:14
Sample Person object using the getter/setter, as a RequireJS module
define(['getterSetter', function(getterSetter) {
return function(options) {
if (typeof options != 'object') {
options = {};
}
// We assume you can't change your name!
this.name = options.name;
// Role, e.g. Web developer