Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
@rwaldron
rwaldron / type.js
Created February 16, 2010 20:36 — forked from rkatic/README.md
(function($){
var toString = Object.prototype.toString;
var class2type = {
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
"[object Function]": "function",
Test:
var foo = { bar : 'barberic'
, baz : 'bazterd'
, duck : 'punch'
};
JSLint Results:
Error:
The example given on Ajaxian:
// See comments below.
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
(function (undefined) {
function detectMutation() {
mutationSupported = true;
this.removeEventListener('DOMAttrModified', detectMutation, false);
}
var forEach = [].forEach,
regex = /^data-(.+)/,
el = document.createElement('div'),
mutationSupported = false,
(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 ) {
(function ($) {
$.fn.pollute = function (pollution) {
pollutants = {
air:"SMOAK",
water:"OIL",
noise:"BLAH"
}
window.emit = function(type) {
<!DOCTYPE html>
<html>
<head>
<title>Workers: Basic Demo</title>
<script>
document.addEventListener('DOMContentLoaded', function () {
var worker = new Worker('worker-javascript-file.js');
<!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
<!DOCTYPE html>
<html>
<head>
<title>$.detonate()</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="jquery.detonate.js"></script>
<script>
$(function () {
<script src="renderer.js"></script>