Skip to content

Instantly share code, notes, and snippets.

View dgowrie's full-sized avatar
🤘

David Gowrie dgowrie

🤘
View GitHub Profile
@dgowrie
dgowrie / recursive-alternative.js
Last active February 26, 2021 23:46
How to recursively flatten a nested array.
// alternative using 'instanceof' check
(function() {
'use strict';
var array = [
'l1a',
'l1b',
@dgowrie
dgowrie / classlike-prototype-module.js
Last active August 29, 2015 14:14
"Class" like structure for JavaScript - a hybrid of the Module Pattern (a locally scoped object variant) and the Prototype Pattern... similar in result to the 'standard' (if such a thing) "Revealing Prototype Pattern"
// "Class" like module pattern
(function (NS) {
'use strict';
// constructor for the Person "Class", attached to global namespace
var Person = NS.Person = function (name) {
this.name = name;
};
@dgowrie
dgowrie / index.html
Created January 30, 2015 04:52
Local Storage example, structured with the Revealing Prototype Pattern for a "Class" like usage, also namespaced
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Localstorage demo</title>
</head>
<script src="Scripts/jquery-2.0.3.min.js"></script>
<script src="Scripts/LocalStorageUtility.js"></script>
<script type="text/javascript">
@dgowrie
dgowrie / Gruntfile.js
Last active August 29, 2015 14:14 — forked from jamesshore/Gruntfile.js
Michal Svoboda's port of [Automatopia](https://github.com/jamesshore/automatopia) to Grunt. See [this comment thread](http://www.letscodejavascript.com/v3/comments/lab/1#comment-1206272962) for context.
/* global module */
(function() {
"use strict";
module.exports = function(grunt) {
var shellOptions = { stdout: true, stderr: true, failOnError: true };
@dgowrie
dgowrie / index.html
Last active August 29, 2015 14:11 — forked from jonnyreeves/index.html
RequireJS demo: OO JavaScript - a 'prototype pattern' modular approach to "Class" definitions. "JavaScript Class Structure using requireJS. The following code shows you how to create a Class definition in one JavaScript file and then import it for use in another."
<!DOCTYPE html>
<html>
<head>
<script data-main="usage" src="http://requirejs.org/docs/release/2.1.15/comments/require.js"></script>
</head>
<body>
<p>Check your JavaScript console for output!</p>
</body>
</head>
@dgowrie
dgowrie / css-stats-ack.sh
Created October 1, 2012 20:06 — forked from pjkix/css-stats-ack.sh
shell script to generate some css file statistics
#!/bin/bash
## v1.0.6
## this script will gernerate css stats
### example output
# CSS STATS
# ----------
# Floats: 132