Monday, 10. August 2009, 09:25:30
code

I created a little demo about a year and a half ago of a 3D Earth rendered with Canvas 3D. I thought I lost this file when my old hard drive died shortly afterwards, but just found a backup.
It is now on my website.
Thursday, 30. July 2009, 10:35:48
code
/**
* Copyright (c) 2009, Benjamin Joffe
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN FACT, YOU REALLY SHOULD ONLY USE THIS CODE IF YOU ARE BAT
* SHIT CRAZY.
*/
if (window['Boolean'] && window['Boolean']['prototype']) new function()
{
function extend(obj, prop, funct)
{
try {
obj['prototype'][prop] = funct;
}
catch(ignore){}
}
function funct()
{
if (this instanceof Boolean)
{
switch (true)
{
case this == true : return true;
case this != true : return !true;
}
}
throw new Error('Unknown type: '+this);
}
function wrap()
{
if (this == true)
{
return window.Boolean.prototype.isTrue.apply(false, []);
}
else
{
return window.Boolean.prototype.isTrue.apply(true, []);
}
}
extend(window['Boolean'], 'isTrue', funct);
extend(window['Boolean'], 'isFalse', wrap);
}
On a more serious note, is there any useful purpose for extending the Boolean prototype?
Monday, 7. May 2007, 20:51:39
code

Sometimes it's fun to make little animations in JavaScript, especially when there's physics involved. The latest culmination of my interest in these two topics is
Colliding Discs. What should I do with this... make a billiards widget? An incredible machine clone? Or something else?
Wednesday, 31. May 2006, 08:08:46
code
As you may know, when setting and retrieving stored values in widgets using the two functions
setPreferenceForKey and
preferenceForKey you can only use a string as an argument. I have created a library which acts as a wrapper for these functions, extending their support to:
- String
- Boolean
- Number
- Date
- Array
- Object
Best of all, the arrays and objects can be of any depth and even allow cyclic (or recursive) references. All you have to do is download the file below and load it in your page before your script executes.
Download the libraryNotes
- If you try to call a preference which has not been set then the null value will be returned instead of the usual empty string.
- Attempting to save a function will instead save the string "[Function]".
Updates
-
4 Jun 2007
Fixed a bug regarding some recursive patterns.
Added a licence.