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",
(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) {
pollutants = {
air:"SMOAK",
water:"OIL",
noise:"BLAH"
}
window.emit = function(type) {
/*
Usages:
$(selector).classList() //returns an array of classnames
$(selector).classList('newclass') //replaces the current element's classes
$(selector).classList(['new', 'class', 'names']) //replaces the current element's classes
*/
jQuery.fn.extend({
classList: function( value ) {
if( value ){
.mouse{
position: absolute;
background-image: url('../images/cursor.png');
width: 15px;
height: 22px;
z-index: 100;
}
<!DOCTYPE html>
<html>
<head>
<title>Dead Simple Twitter Search API jQuery Feed</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="jQuery.twitterFeed.js"></script>
<script src="jquery.twitter-usage-ex.js"></script>
<link href="jQuery.twitterFeed.css" media="screen" rel="stylesheet" type="text/css">
</head>
<body>
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// Rick says: There is more then one way to optimize this
foo ? bar.doSomething(el) : bar.doSomethingElse(el);
/*!
* postMessage detector - v0.1pre - 9/15/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// If `window.postMessage.complex` is true, postMessage can pass complex non-string
@rwaldron
rwaldron / error.php
Created September 27, 2010 17:26 — forked from jeresig/error.php
<?php header('HTTP/1.0 500 Internal Server Error'); exit; ?>