Skip to content

Instantly share code, notes, and snippets.

View DawnPaladin's full-sized avatar

James Harris DawnPaladin

View GitHub Profile
@DawnPaladin
DawnPaladin / gist:d6a47fe49611b6388123
Created December 17, 2014 20:07
When the browser would fire an alert() window, it begins debugging instead, allowing you to step through the code.
window.alert = function(msg) { debugger; } ;
@DawnPaladin
DawnPaladin / gist:9d31899a64635ad59ebe
Created December 17, 2014 20:08
Bind myFunction to an event handler and pass myArgument to it
jQuery('#element').click({param1: myArgument }, myFunction);
@DawnPaladin
DawnPaladin / gist:7b2b9edc73a6468c9a61
Created December 17, 2014 20:09
Override a Dijit button to ignore its default functionality and do your bidding instead.
dijit.byId('widgetID').onClick = handlerFunction;
@DawnPaladin
DawnPaladin / gist:92cd34c82af94590eb40
Created January 5, 2015 20:48
Disable all Dijit buttons in an area
dojo.query(".addToCartBtn, .dijitDropDownButton", "searchResultsContainer") // find Add to Cart/Add to Wishlist buttons in #searchResultsContainer
.map(dijit.byNode) // convert from DOM nodes to Dijit refs (see http://stackoverflow.com/a/1375150/1805453)
.forEach(function(element){ // iterate over results
element.attr('disabled', true);
}
);
@DawnPaladin
DawnPaladin / .gitignore
Created January 28, 2015 20:32
Personal gitignore file
Thumbs.db
*.sublime-workspace
AdobeFnt16.lst
*.idlk
dwsync.xml
node_modules/
@DawnPaladin
DawnPaladin / .jshintrc
Created February 21, 2015 21:35
Personal .jshintrc file
{
"indent": 1
}
@DawnPaladin
DawnPaladin / index.html
Last active August 29, 2015 14:16
HTML5 boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML5 boilerplate – all you really need…</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
javascript:(function(e){e.setAttribute("src","http://172.18.18.4:8080/target/target-script-min.js#anonymous");document.getElementsByTagName("body")[0].appendChild(e);})(document.createElement("script"));void(0);
/* A list
Objects, as generic blobs of values, can be used to build all sorts of data structures. A common data structure is the list (not to be confused with the array). A list is a nested set of objects, with the first object holding a reference to the second, the second to the third, and so on.
var list = {
value: 1,
rest: {
value: 2,
rest: {
value: 3,
@DawnPaladin
DawnPaladin / gist:5b426f5a31731685199c
Last active August 29, 2015 14:21
Annotated recursive object comparison
/* Deep comparison
The == operator compares objects by identity. But sometimes, you would prefer to compare the values of their actual properties.
Write a function, deepEqual, that takes two values and returns true only if they are the same value or are objects with the same properties whose values are also equal when compared with a recursive call to deepEqual.
To find out whether to compare two things by identity (use the === operator for that) or by looking at their properties, you can use the typeof operator. If it produces "object" for both values, you should do a deep comparison. But you have to take one silly exception into account: by a historical accident, typeof null also produces "object".
Hints: