Skip to content

Instantly share code, notes, and snippets.

View dgowrie's full-sized avatar
🤘

David Gowrie dgowrie

🤘
View GitHub Profile
@dgowrie
dgowrie / gist:674b7b31e2f91c244fc7
Created March 24, 2016 16:36 — forked from pgoldrbx/gist:d730cda13de64db69175
This ___ isn't working... did I do something dumb?

Why aren't I seeing my changes?

What do you mean 404 error?!?

Oh come ON, I just DID that!

How often are you working on something and are stuck trying to debug some irritation problem, only to discover after time that you've done something embarrassingly stupid? It's good to go through a checklist of "dumb" questions before spending an hour in the debugger or pouring over changesets.

Example:

  • Is the computer plugged in? (classic tech support!)
@dgowrie
dgowrie / prototype-pattern.js
Created October 4, 2015 06:44
Yet another iteration of (revealing)Prototype Pattern with private/public methods
var myPrototypeModule = (function() {
'use strict';
var privateVar = 'Alex Castrounis',
count = 0;
function PrototypeModule(name) {
this.name = name;
}
function privateFunction() {
@dgowrie
dgowrie / git-feature-workflow.md
Last active August 29, 2015 14:27 — forked from blackfalcon/git-feature-workflow.md
Git basics - a general workflow

There are many Git workflows out there, I heavily suggest also reading the atlassian.com [Git Workflow][article] article as there is more detail then presented here.

The two prevailing workflows are [Gitflow][gitflow] and [feature branches][feature]. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited.

When using Bash in the command line, it leaves a bit to be desired when it comes to awareness of state. I would suggest following these instructions on [setting up GIT Bash autocompletion][git-auto].

Basic branching

When working with a centralized workflow the concepts are simple, master represented the official history and is always deployable. With each now scope of work, aka feature, the developer is to create a new branch. For clarity, make sure to use descriptive names like transaction-fail-message or github-oauth for your branches.

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@dgowrie
dgowrie / gist:c24da624141bb77d5eff
Created June 11, 2015 22:13
Revealing Module Pattern, with internal prototype / constructor pattern
var myModule = ( function($, undefined) {
var _person = function(firstName, lastName, age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
};
_person.prototype.fullName = function() {
return this.firstName + ' ' + this.lastName;
};
@dgowrie
dgowrie / BEM-buttons.css
Last active August 29, 2015 14:17
HTML Class naming conventions: BEM-like syntax example - Buttons
/* Use class-attribute selectors for modules with common styles */
[class*="btn--"] {
background: #CCC;
padding: .5em;
text-decoration: none;
}
/* Target individual module modifiers as needed */
.btn--add {
background-image:('icon-plus.png') 0 50% no-repeat;
@dgowrie
dgowrie / revealing-prototype-pattern.js
Last active December 18, 2015 17:40
Public / private members on a "class" via the Pseudoclassical pattern using Prototypal Inheritance combined with the Revealing Module pattern - AKA a "revealing prototype pattern"
// constructor
function Person(name) {
this.name = name;
// etc... but no methods here
}
// prototype for all methods, using an IIFE with a returned object for 'public' methods
Person.prototype = (function() {
@dgowrie
dgowrie / extending-prototype.js
Last active August 29, 2015 14:15
Prototypal Inheritance - extending a prototype when creating a 'subclass'
// Demonstrates the side effects of using 'new' to extend a prototype and the reason to use Object.create (with a shim for IE8 support).
//
// It can be a problem to use 'new' when extending a superclass because you're actually running the superclass's constructor.
// Using Object.create() avoids the problem of unintentional side effects from running the superclass constructor.
// see http://www.objectplayground.com/ for details
// Parent class constructor
function Parent() {
alert("side effect!");
}
@dgowrie
dgowrie / prototypal-inheritance-crockford
Created February 5, 2015 05:45
Prototypal inheritance in JavaScript as described by Douglas Crockford
Prototypal inheritance in JavaScript is described by Douglas Crockford as: you make prototype objects, and then ... make new instances. Objects are mutable in JavaScript, so we can augment the new instances, giving them new fields and methods. These can then act as prototypes for even newer objects. We don't need classes to make lots of similar objects....Objects inherit from objects. What could be more object oriented than that?
http://javascript.crockford.com/prototypal.html
@dgowrie
dgowrie / recursively-flatten-nested-hash.js
Last active August 29, 2015 14:14
How to recursively flatten a nested hash (object literal) in JavaScript.
// alternative approach for testing if value is an Object
(function() {
'use strict';
var hash = {
level1a: 'l1a',
level1b: 'l1b',
level1c: {