Skip to content

Instantly share code, notes, and snippets.

Rick Waldron rwaldron

Block or report user

Report or block rwaldron

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View type.js
(function($){
var toString = Object.prototype.toString;
var class2type = {
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
"[object Function]": "function",
View Comma-First Code Writing Is Bad
Test:
var foo = { bar : 'barberic'
, baz : 'bazterd'
, duck : 'punch'
};
JSLint Results:
Error:
View gist:360217
The example given on Ajaxian:
// See comments below.
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
View html5-data.js
(function (undefined) {
function detectMutation() {
mutationSupported = true;
this.removeEventListener('DOMAttrModified', detectMutation, false);
}
var forEach = [].forEach,
regex = /^data-(.+)/,
el = document.createElement('div'),
mutationSupported = false,
View jquery.pollute.js
(function ($) {
$.fn.pollute = function (pollution) {
// first we extend the pollution object to the window, nice!
$.extend(window, pollution);
// make sure we're really nasty, and pollute all the elements as well.
return this.each(function () {
for ( var junk in pollution ) {
View jquery.pollute.js
(function ($) {
$.fn.pollute = function (pollution) {
pollutants = {
air:"SMOAK",
water:"OIL",
noise:"BLAH"
}
window.emit = function(type) {
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Workers: Basic Demo</title>
<script>
document.addEventListener('DOMContentLoaded', function () {
var worker = new Worker('worker-javascript-file.js');
View compatible-filtering-worker.html
<!DOCTYPE html>
<html>
<head>
<title>Workers: Compatibility</title>
<script>
// This script is executed in the main window
/*
we'll use a worker to filter a huge data set
View jquery.detonate.html
<!DOCTYPE html>
<html>
<head>
<title>$.detonate()</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="jquery.detonate.js"></script>
<script>
$(function () {
View renderer.html
<script src="renderer.js"></script>
You can’t perform that action at this time.