Skip to content

Instantly share code, notes, and snippets.

View jr-codes's full-sized avatar

JR Shampang jr-codes

  • DISCO
  • Milwaukee, WI
View GitHub Profile
@dustinboston
dustinboston / rtree.js
Created August 7, 2012 19:50
Generate dependency tree for RequireJS apps
// Usage:
//
// 1. Put this in the file that gets first loaded by RequireJS
// 2. Once the page has loaded, type window.rtree.map() in the console
// This will map all dependencies in the window.rtree.tree object
// 3. To generate UML call window.rtree.toUml(). The output can be used
// here: http://yuml.me/diagram/scruffy/class/draw
requirejs.onResourceLoad = function (context, map, depMaps) {
if (!window.rtree) {
window.rtree = {};
@mathiasbynens
mathiasbynens / unsafeWindow.user.js
Created August 13, 2011 13:21
`unsafeWindow` polyfill (for use in user scripts)
// ==UserScript==
// @name Emulate `unsafeWindow` in browsers that don’t support it.
// ==/UserScript==
// http://mths.be/unsafewindow
window.unsafeWindow || (
unsafeWindow = (function() {
var el = document.createElement('p');
el.setAttribute('onclick', 'return window;');
return el.onclick();
@aidilfbk
aidilfbk / disableSelection.jquery.js
Created August 14, 2010 11:48
jQuery plugin to prevent selection of text
// Usage: $("elements").disableSelection()
(function($){
$.fn.extend({
disableSelection : function() {
return this.each(function() {
this.onselectstart = function(){return false;};
this.unselectable = "on";
jQuery(this).css({'-moz-user-select': 'none', '-webkit-user-select': 'none', 'user-select': 'none');
});