Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Alberto Arena albertoarena

🎯
Focusing
View GitHub Profile
@albertoarena
albertoarena / person.js
Last active Aug 29, 2015
Sample Person object using the getter/setter, as a RequireJS module
View person.js
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
@albertoarena
albertoarena / getterSetter.js
Last active Aug 29, 2015
Getter/Setter RequireJS module
View getterSetter.js
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 / FileStorageFactory.php
Last active Nov 11, 2020
Using the Factory method pattern to have different file storage mechanisms.
View FileStorageFactory.php
<?php
/**
* Class FileStorageFactory
* A factory class that instantiates the appropriate FileStorage engine
*/
class MyProject_Service_FileStorageFactory
{
/**
* Available file storage mechanisms