Skip to content

Instantly share code, notes, and snippets.

@mralexho
mralexho / inheritPrototype.js
Created Feb 24, 2015
function that makes the child object inherit from parent object
View inheritPrototype.js
function inheritPrototype(childObject, parentObject){
var parentCopy = Object.create(parentObject.prototype);
parentCopy.constructor = childObject;
childObject.prototype = parentCopy;
}
@mralexho
mralexho / singleton.pattern.js
Last active Aug 29, 2015
a singleton module
View singleton.pattern.js
var singleton = function() {
var privateVariable;
function privateFunction(x) {
...privateVariable...
}
return {
first method: function (a, b) {
...privateVariable...
},
second method: function (a, b) {
View homebrew.txt
# To keep the Homebrew itself up-to-date, and fetch the newest version from GitHub use:
brew update
# After updating the brew, check which formulae have an updated version available, display detailed version information to see if you have more than one older version laying around:
brew outdated --verbose
# Remove broken symlinks
brew prune
@mralexho
mralexho / setup-dev.sh
Last active Mar 7, 2022
Install homebrew, nginx, mysql, php55, and composer on Mac OS X
View setup-dev.sh
#!/bin/bash
# install homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
View anonymous.pattern.js
/**
* Self-executing JavaScript pattern
*/
// undefined = true; works in javascript
// passing undefined as a param guarantees undefined is “undefined”
(function(window, document, undefined) {
// ...
})(this, document); // this = window
@mralexho
mralexho / option-list-us-states.txt
Created Dec 8, 2014
option list for U.S. States
View option-list-us-states.txt
AL|Alabama
AK|Alaska
AZ|Arizona
AR|Arkansas
CA|California
CO|Colorado
CT|Connecticut
DE|Delaware
DC|District Of Columbia
FL|Florida
View reflection.php
<?php
/**
* PHP Reflection API
* Examines the inner workings of functions, classes, and objects
*/
Reflection::export(new ReflectionClass('class_name'));
@mralexho
mralexho / jquery.plugin-template.js
Created Jun 16, 2014
a template for creating jQuery plugins
View jquery.plugin-template.js
// remember to change every instance of "pluginName" to the name of your plugin!
(function($) {
// here it goes!
$.fn.pluginName = function(method) {
// plugin's default options
var defaults = {
foo: 'bar'
};
// this will hold the merged default and user-provided properties
// you will have to access the plugin's properties through this object!