Skip to content

Instantly share code, notes, and snippets.

View mralexho's full-sized avatar
💭
☕️

Alex Ho mralexho

💭
☕️
  • New York City Economic Development Corporation
  • New York
View GitHub Profile
@mralexho
mralexho / jquery.plugin-template.js
Created June 16, 2014 16:52
a template for creating jQuery plugins
// 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!
<?php
/**
* PHP Reflection API
* Examines the inner workings of functions, classes, and objects
*/
Reflection::export(new ReflectionClass('class_name'));
@mralexho
mralexho / option-list-us-states.txt
Created December 8, 2014 15:29
option list for U.S. States
AL|Alabama
AK|Alaska
AZ|Arizona
AR|Arkansas
CA|California
CO|Colorado
CT|Connecticut
DE|Delaware
DC|District Of Columbia
FL|Florida
@mralexho
mralexho / anonymous.pattern.js
Created December 26, 2014 16:59
javascript pattern
/**
* 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
# 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 / singleton.pattern.js
Last active August 29, 2015 14:15
a singleton module
var singleton = function() {
var privateVariable;
function privateFunction(x) {
...privateVariable...
}
return {
first method: function (a, b) {
...privateVariable...
},
second method: function (a, b) {
@mralexho
mralexho / inheritPrototype.js
Created February 24, 2015 19:42
function that makes the child object inherit from parent object
function inheritPrototype(childObject, parentObject){
var parentCopy = Object.create(parentObject.prototype);
parentCopy.constructor = childObject;
childObject.prototype = parentCopy;
}
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
this.isApproved = this.searchList(this.browser, this.version);
if(this.OS == "iPad")document.documentElement.className += ' iOS';
# find out what version of Linux (distro) you are running
$ cat /etc/*-release
# find out kernel, version number, machine hardware name
$ uname -mrs
var myNamespace = (function () {
var myPrivateVar = 0;
var myPrivateMethod = function (someText) {
console.log(someText); };
return {
myPublicVar: "foo",
myPublicFunction: function (bar) {
myPrivateVar++;
myPrivateMethod(bar);
} };