Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
/**
* This library defines magic properties and methods
* for objects. Generic hooks are: __get__, __set__,
* __delete__, __count__ and __noSuchProperty__.
*
* Used features: Harmony (ES6) proxies.
*
* Tested in FF4 beta.
*
* @author Dmitry A. Soshnikov <[email protected]>
/* ------------------------------ Main Class ------------------------------ */
// Returns "instances" of itself which are actually functions.
function Ben ( greeting ) { var Parent, scope
function Scope () {
// Here is where you put your normal constructor junk
this.greeting = greeting
this.colours = [ 'yellow', 0xFFFFFF ]
}
// Magic
@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; ?>
/*!
* 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
// 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);
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
<!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>
.mouse{
position: absolute;
background-image: url('../images/cursor.png');
width: 15px;
height: 22px;
z-index: 100;
}
/*
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 ){
(function ($) {
$.fn.pollute = function (pollution) {
pollutants = {
air:"SMOAK",
water:"OIL",
noise:"BLAH"
}
window.emit = function(type) {