Skip to content

Instantly share code, notes, and snippets.

View draeton's full-sized avatar

Matthew Kimball-Cobbs draeton

View GitHub Profile
@draeton
draeton / manifest.json
Created July 13, 2012 15:10
Testing the chrome extension history API
{
"name": "Test",
"version": "0.1",
"manifest_version": 2,
"description": "Test",
"permissions": [
"history"
],
"background": {
"scripts": [
@draeton
draeton / jquery.readdataattr.js
Created February 28, 2012 02:45
Get HTML5 data attributes with no type coercion
/**
* jQuery.readDataAttr
*
* Gets html5 data attributes without type coercion.
* If called with no parameters, returns an object with all
* current data-* values.
*
* @param {String} [key] Optional; if set, return only this
* value
* @return {*} Return either all values, or the value at key
@draeton
draeton / jquery.maxz.js
Created February 24, 2012 08:50
$.maxZ
// inspired by:
// http://snipplr.com/view.php?codeview&id=15214
(function ($) {
$.maxZ = function () {
var $all = $("body > *");
return Math.max.apply(Math, $.map($all, function (el) {
var $el = $(el);
var z = 0;
@draeton
draeton / deeplink.js
Created February 15, 2012 16:01
Deeplinking?
@draeton
draeton / ngbs.u.anchor.js
Created January 24, 2012 16:53
A URL parsing utility
/**
* ngbs.u.anchor - A URL parsing utility
*/
/*global ngbs */
var ngbs = ngbs || {};
ngbs.u = ngbs.u || {};
ngbs.u.anchor = (function (window, document, location) {
"use strict";
@draeton
draeton / anchor.js
Created January 9, 2012 15:15
Anchor - A URL parsing utility
/**
* Anchor - A URL parsing utility
*
* Copyright 2012, Matthew Cobbs
* MIT licensed
*
* Methods:
*
* getSearchVars - returns a key-value object with the parameters in the URL search
* setSearchVars(o) - sets parameters using a key-value object in the URL search
@draeton
draeton / LICENSE
Created December 28, 2011 06:22
Fibonacci in Python
Copyright (c) 2011, Matthew Cobbs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@draeton
draeton / base.js
Created December 22, 2011 05:10
Playing with classes and inheritance
/*
* This has essentially turned into Resig's Simple JavaScript Inheritance
* with some minor modifications for class names and use strict,
* and getters ans setters
* http://ejohn.org/blog/simple-javascript-inheritance/
* http://ejohn.org/blog/javascript-getters-and-setters/
*/
(function (window) {
"use strict";
@draeton
draeton / file-extension-filter.js
Created December 9, 2011 21:58
Filter file names by extension
var list = "me.jpg,me.png,me.txt,me.zip,me.apple".split(",");
var re = /.+\.(?!jpg|jpeg|gif|png)/i;
list.forEach(function (v, i) {
console.log(v, re.test(v));
});
@draeton
draeton / node.js
Created December 9, 2011 03:48
Nodes with children
function Node ( val, parent ) {
this.value = val;
this.setParent( parent );
this.children = [];
}
Node.prototype = {
addChild: function ( val ) {
var node = val instanceof Node ? val : new Node( val );
node.setParent( this );