Skip to content

Instantly share code, notes, and snippets.

View spiralx's full-sized avatar

James Skinner spiralx

View GitHub Profile
@spiralx
spiralx / github-npm-autolink.user.js
Last active August 29, 2015 14:05
GitHub package.json dependency linker
@spiralx
spiralx / jquery-mutation-summary.js
Created October 31, 2014 01:55
jquery-mutation-summary.js
/*!
* @license jquery-mutation-summary
* Copyright © 2012, 2013, 2014, Joel Purra <http://joelpurra.com/>
* Released under MIT, BSD and GPL license. Comply with at least one.
*
* A jQuery wrapper/plugin for mutation-summary, the DOM mutation-observers wrapper.
* http://joelpurra.github.com/jquery-mutation-summary
*
* "Mutation Summary is a JavaScript library that makes observing changes to the DOM fast, easy and safe."
* http://code.google.com/p/mutation-summary/
@spiralx
spiralx / parse-uri-es6.js
Last active December 22, 2015 09:38
ES5 and 6 functions to parse URIs mostly following the RFC 1738 spec
/*jshint asi:true */
;(function(global) {
'use strict'
const parser = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
queryKeyParser = /(?:^|&)([^&=]*)=?([^&]*)/g,
keys = "href protocol authority userInfo user password host port relative path directory file query anchor".split(" ");
/**
@spiralx
spiralx / jQuery.batch.js
Created September 10, 2013 16:18
Creates jQuery instance methods for returning data from each item selected e.g. $el.attrs(), $.texts()
(function($) {
$.fn.batch = function(method, args) {
var func = $.fn[method], results = [];
this.each(function() {
results.push(func.apply(this, args));
});
return results;
};
var funcs = "attr css=styles prop html text val offset width height".split(" ");
anonymous
anonymous / form.json
Created November 8, 2016 22:08
A saved configuration for a schema form example, http://textalk.github.io/angular-schema-form/examples/bootstrap-example.html
[
{
"type": "help",
"helpvalue": "Complex keys are only supported with AngularJS version 1.3.x, see <a href=\"https://github.com/Textalk/angular-schema-form/blob/master/docs/knownlimitations.md\">known limitations</a> in the docs."
},
"title",
"preference",
{
"key": "shareholders",
"title": "Shareholders",
@spiralx
spiralx / regex-named-groups.js
Created April 1, 2014 01:16
Regular Expressions with Named Groups
/**
* Allows you to specify named groups in regular expressions like in Perl/Python/.NET/etc. You have to
* use a string to specify the regex, and the function returns an object that has `exec` and `replace`
* functions like a normal RegExp object, but matches they generate have keys for the values of the named
* groups.
*
* n = NamedRegExp("(?<protocol>http|ftp)://(?<host>[\\w-]+\\.com)(?<path>/.+\\.html)?$");
* res = n.exec("http://foobar.com"); -> res.protocol = http, res.host = foobar.com res.path = undefined
* res = n.exec("http://foobar.com/"); -> res.protocol = http, res.host = foobar.com res.path = /
@spiralx
spiralx / jquery-extras.js
Last active November 15, 2016 15:38
jQuery extras for use in user scripts
(function($) {
'use strict';
if (typeof $.format === 'function') {
return;
}
// --------------------------------------------------------------------
// Defined variables and constants.
@spiralx
spiralx / bling.js
Last active November 15, 2016 15:39 — forked from paulirish/bling.js
bling.js fork with multiple event binding
/*jshint asi:true, proto:true */
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function(names, fn) {
var self = this
names.split(' ').forEach(function(name) {
@rodneyrehm
rodneyrehm / demo-list.html
Created May 28, 2012 11:08
jQuery Snippets - jQuery.sortChildren()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>sorting lists</title>
<script src="jquery-1.7.2.min.js"></script>
<script src="jquery.sortChildren.js"></script>
<script>
@spiralx
spiralx / all-colours.js
Last active April 7, 2017 07:58
Collected DevTool snippets
// allcolors.js
// https://github.com/bgrins/devtools-snippets
// Print out CSS colors used in elements on the page.
(function() {
'use strict'
const BOLD = 'font-weight: bold;'
const LINK = 'text-decoration: underline; color: #05f'
const NORMAL = 'font-weight: normal; text-decoration: none; color: black; background-color: white; display: inline'