Skip to content

Instantly share code, notes, and snippets.

@softwarespot
softwarespot / jsonp.php
Created May 1, 2016 19:09 — forked from mathiasbynens/jsonp.php
Basic JSON/JSON-P service in PHP
<?php
// Prevent content sniffing attacks such as http://mths.be/bst.
header('X-Content-Type-Options: nosniff');
// Note: The user-provided callback name must be filtered to prevent attack
// vectors. This script simply removes any symbols other than `[a-zA-Z0-9$_]`
// from the input. Sadly, this blocks the use of some valid JavaScript
// identifiers, and also accepts a few invalid ones. See
// http://mathiasbynens.be/notes/javascript-identifiers for details.
@softwarespot
softwarespot / eventUtility.js
Last active October 24, 2017 06:45 — forked from justinwhall/eventUtility.js
JS | Cross Browsers Event Utility Object
var EventsUtility = {
addEvent: function (element, type, callback) {
if (typeof addEventListener !== 'undefined') {
element.addEventListener(type, callback, false);
} else if (typeof attachEvent !== 'undefined') {
element.attachEvent('on' + type, callback); // IE, legacy browser
} else {
element['on' + type] = callback;
}
},
@softwarespot
softwarespot / pubsub.md
Last active September 13, 2015 17:09 — forked from learncodeacademy/pubsub.js
PubSub module in vanillaJS
@softwarespot
softwarespot / jquery.ba-tinypubsub.js
Last active September 30, 2015 06:22 — forked from rwaldron/jquery.ba-tinypubsub.js
PubSub module in jQuery
/*
* jQuery Tiny Pub/Sub - v0.1 - 2015/08/07
* http://benalman.com/
*
* Original Copyright (c) 2010 'Cowboy' Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Made awesome by Rick Waldron, with additional ideas by Jeffrey Way and softwarespot
* URL: https://gist.github.com/rwaldron/705311