Skip to content

Instantly share code, notes, and snippets.

View dcneiner's full-sized avatar

Doug Neiner dcneiner

View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@eliperelman
eliperelman / example.js
Last active September 26, 2015 08:08
Guaranteed Instances
var Car = function(make, model, color) {
this.make = make;
this.model = model;
this.color = color;
};
// This way works:
var pinto = new Car('ford', 'pinto', 'green');
// but this doesn't:
var pinto = Car('ford', 'pinto', 'green');
// Original code from David Walsh
jQuery(document).ready(function() {
/* fetch elements */
jQuery('form.follow-form').each(function() {
/* stop form event */
jQuery(this).bind('submit',function(e) {
/* stop event */
e.preventDefault();
/* "on request" */
jQuery(this).find('i').addClass('active');