Skip to content

Instantly share code, notes, and snippets.

View mildfuzz's full-sized avatar

John Farrow mildfuzz

View GitHub Profile
@mildfuzz
mildfuzz / arraysAreEqual.js
Created February 11, 2016 12:22
Compare two arrays
function arraysAreEqual(a, b) {
if (a.length !== b.length) {return false;}
// remove all index that match, should be zero length array at end if equal
return !a.filter(function(item, index) {
return a[index] !== b[index];
}).length;
};
@mildfuzz
mildfuzz / cross-platform-module-definition.js
Created February 10, 2016 13:29
Cross Module Loading Platform Module Definition
(function(){
"use strict";
var module = function(){
//my module code};
};
if(typeof define !== 'undefined' && typeof define.amd !== 'undefined' ){
define(function(){
return module;
});
} else if(typeof module !== 'undefined' && typeof module.exports !== 'undefined' ){
@mildfuzz
mildfuzz / arrayContainsSub.js
Last active December 8, 2015 09:43
arrayContainsSub matches arrays within arrays
function arrayContainsSub(arr, sub) {
var first = sub[0],
i = 0,
starts = [];
while (arr.indexOf(first, i) >= 0) {
starts.push(arr.indexOf(first, i));
i = arr.indexOf(first, i) + 1;
}
@mildfuzz
mildfuzz / orientation.js
Last active October 22, 2015 13:10
Shim for adding window.orientation to desktop environments. Only does 0 or 90, not -90
(function(win) {
if ('orientation' in win) return;
if ('matchMedia' in win) {
var mtch = win.matchMedia('(orientation: portrait)');
win.orientation = mtch.matches ? 0 : 90;
mtch.addListener(function(m) {
win.orientation = m.matches ? 0 : 90;
});
}
})(window);
@mildfuzz
mildfuzz / authStore.js
Created June 16, 2015 08:48
authstore
define(['EventEmitter'], function(EventEmitter) {
var AuthStore = new EventEmitter(),
newMemberEvent = 'newMemberEvent',
clearMemberEvent = 'clearMemberEvent',
store = {};
AuthStore.setMember = function(member) {
store.member = member;
this.emit(newMemberEvent);
@mildfuzz
mildfuzz / lint.json
Created March 25, 2015 09:37
mylintsettings
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"gjslint": {
if(mediaRequired && typeof require === 'function'){
// we need to load the bbc audio player
require(['bump-3'],function ($) {
media: {
playlist: {
title: 'your title'
}
}
@mildfuzz
mildfuzz / maker-client-lib-doc.md
Created March 5, 2015 15:40
Maker Client Lib

Maker Lib

Module returns abstracted constructor function. This should be instantiated by the DMK Container, resulting object passed into the DMK contructor.

var make = Make(token, container);
require(['path/to/dmk/main.js'], function(dmk){
    dmk.init(make);
});
@mildfuzz
mildfuzz / dmk-container.ejs
Created February 26, 2015 09:56
dmk-container
<% include header %>
<% include alert %>
<div id="dmk-container-holder">
<h2>DMK Container</h2>
</div>
<script type="text/javascript">
var token = '<%= token %>',
var path = '<%= path %>';// http://localhost:8080/main.js || http://dmk.makespace.org/147862/main.js
var attr = {