Skip to content

Instantly share code, notes, and snippets.

View mparke's full-sized avatar

Matthew Parke mparke

View GitHub Profile
(function ($, Namespace) {
'use strict';
var slice = Array.prototype.slice;
function widget (widgetName, constructor) {
var namespace = 'fifty.' + widgetName;
return function (options) {
var $el = $(this),
args = slice.call(arguments),
@mparke
mparke / events_mixin.js
Created June 18, 2014 20:37
EventsMixin
(function(App, Array) {
'use strict';
var slice = Array.prototype.slice;
function Events () {
var events = {};
function on (eventName, callback, context) {
if (!events[eventName]) {
events[eventName] = [];
@mparke
mparke / package.json
Created November 20, 2014 04:24
Example package.json
{
"name": "modulejs",
"version": "0.0.1",
"description": "A new module",
"license": "MIT",
"private": true,
"authors": [
"mparke"
],
"devDependencies": {
@mparke
mparke / base.js
Last active December 17, 2015 20:29
Backbone base view with Handlebars template rendering
App.Views.Base = Backbone.View.extend({
templateName: null,
render: function(){
var data;
if(this.templateName !== null){
if(this.model !== null){
data = this.model.toJSON()
@mparke
mparke / revealing_module
Created May 31, 2013 14:26
Revealing Module Pattern
var module = (function(){
var privateNum = 10;
function privateFn(){
return privateNum * 2;
}
function publicFn(){
return privateFn();
}
@mparke
mparke / canvas_drawing.js
Created June 2, 2013 16:36
Canvas Line Drawing
(function(){
var ctx = document.getElementById('draw-canvas').getContext('2d'),
penX = [],
penY = [],
saveStates = [],
drawOn = false,
trackingInitialized = false,
canvasWidth, canvasHeight;
ctx.strokeStyle = '#000';
@mparke
mparke / gist:5855304
Created June 25, 2013 01:50
Matrix shift and unshift prototype
function shift(){
var yLen = mx.length,
row;
if(yLen > 0){
row = mx[0];
if(row.length > 0){
return row.shift();
}else{
@mparke
mparke / gist:5855348
Last active December 18, 2015 22:38
Matrix find function intended for use with pixel positions
//searches the matrix for x and y pixel position using binary search
function find(x, y){
var rowData = binarySearch(mx, 0, mx.length - 1, 'y', this.ySize, y);
var colData = binarySearch(rowData.x, 0, rowData.x.length - 1, 'x', this.xSize, x);
return colData;
}
function binarySearch(arr, start, stop, bottomBoundKey, size, val){
var midpoint, data, midBottomBound, midTopBound;
@mparke
mparke / base.js
Created August 2, 2013 19:17
Backbone base view with Handlebars template rendering and nested view support.
App.Views.Base = Backbone.View.extend({
templateName: null,
model: null,
render: function(options){
var data;
if(this.templateName !== null){
if(this.model !== null){
data = this.model.toJSON()
//---------------------------------------------
// ************** Sonifizer.js **************
//---------------------------------------------
// http://www.Sonifizer.com/Sonifizer.js
//---------------------------------------------
// Andrew Madden
//---------------------------------------------
var Sonifizer_Base_URL = "http://www.Sonifizer.com";