Skip to content

Instantly share code, notes, and snippets.

View spiralx's full-sized avatar

James Skinner spiralx

View GitHub Profile
// Primitive hash function that for a string returns a positive 32 bit int
// Do not use in production, use murmur3 or fnv1
// You can improve this by changing 5 to 31
Object.defineProperty(String.prototype, 'hashCode', {
value: function() {
var hash = 0, i, chr;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
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",
@btroncone
btroncone / ngrxintro.md
Last active February 9, 2024 15:37
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@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'
@Avaq
Avaq / combinators.js
Last active March 18, 2024 20:49
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@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) {
@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 / 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 / github-npm-autolink.user.js
Last active August 29, 2015 14:05
GitHub package.json dependency linker
@staltz
staltz / introrx.md
Last active April 15, 2024 10:24
The introduction to Reactive Programming you've been missing