Projects

What I didn’t get to

Posted by oliver
Tue, 01/01/2008 - 07:25

Here are some of the weekend projects that I didn’t finish this year. These aren’t good enough to put on my project list or my sources page. Some of these aren’t even working, and some of them I might not finish at all (most of my weekends are spoken for). And some of them I can’t bear to look at (I’m not proud of the code, and don’t want to be judged by it…), but I’m making myself put them out there anyway. I feel bad for the neglected little things, trapped on my hard drive, and I’d like to let them see the sun, even if just briefly before they flicker out and die.  read more »

Sequentially: Temporal and Frequency Adverbs for JavaScript

Posted by oliver
Sat, 11/24/2007 - 21:06

Sequentially is a JavaScript library for asychronous programming. It makes it easy to define functions that are called later, or periodically, or that can be called only a certain number of times, or only at a certain frequency.  read more »

// Call a function f five times in a row
f.only(5).repeatedly()
// Call f five times, at one second intervals
f.only(5).periodically()
// Make a new function g that calls through to f at most five times,
// no matter how often g is called
var g = f.only(5)
// Make a new function g that calls f at most once per minute,

Functional Javascript 1.0.2

Posted by oliver
Sun, 11/11/2007 - 23:34

Thanks to everyone who has commented or contributed, praised or pitched in —- I’ve released an update to Functional Javascript, with these changes:

New features

- Rhino compatibility. I think —- at least it loads now, and a couple of hand tests work; i have yet to port the testing tool. (Credit: Reginald Braithwaite)

Optimizations

- More efficient Array.slice. (Credit: Dean Edwards) – Memoize Function.lambda. (Credit: henrah)  read more »

Functional JavaScript

Posted by oliver
Sun, 07/22/2007 - 03:54

Functional is a JavaScript library for functional programming. It defines the standard higher-order functions (map, reduce, filter) that you can read about elsewhere on the web. It also defines functions for partial function application and function-level programming: curry, partial, compose, guard, and until. Finally, it introduces “string lambdas”, which let you write 'x -> x+1', 'x+1', or even '+1' as synonyms for function(x) {return x+1}.  read more »

Wide URLs with WideURL.com

Posted by oliver
Sat, 04/01/2006 - 17:36

For years now, I’ve been a great fan of TinyURL.com. That web site allows you to create a short representation of a longer URL, for use in email.

One of the problems with those URLs, though, and with URLs in general, is that they’re misleadingly short. A particular web page may have a lot of significance, but if it doesn’t take up much of your message, there’s just no way for the recipient to see this at a glance.

WideURL.com fixes this. It creates an URL with more visual impact.

For example, here’s the WideURL for this post: http://wideurl.com/aitch-tee-tee-pea-colon-double-slash-oh-ess-tee-double-ee-ell-ee-dot-see-oh-em-slash-aye-are-see-aitch-eye-vee-ee-ess-slash-two-double-zero-six-slash-zero-four-slash-doubleyou-eye-dee-ee-you-are-ell.  read more »

A Functional Diversion

Posted by oliver
Fri, 03/24/2006 - 03:36

Even my friends who aren’t into functional programming find something curously relaxing about this. (And the companion site here.)

I bought foldr.com a year ago when I thought I might do something like Flickr for other types of information. I didn’t realize until last week what I was sitting on. :-)

Update: The use of the infinity symbol sparked a lively discussion on LtU.

JavaScript Gradient Roundrects

Posted by oliver
Thu, 03/23/2006 - 20:52

JavaScript Gradient Roundrects adds gradient roundrects to an HTML page, without images. It uses the WHATWG canvas tag if it’s available. Otherwise it uses a stack of divs, whose heights are adaptively chosen according to the height of the graded element, the color components, and the radius curvature. There’s a demo here.

I also wrote a JavaScript CSS parser that lets you attach gradients to an element without writing code. You do this by including CSS inside a div tag whose class is ‘style’.  read more »

Inline JavaScript Console

Posted by oliver
Sat, 03/04/2006 - 07:10

Last week for the first time I did some serious browser JavaScript programming. I put the following tools to good use, but ran against limits with each of them:

is terrific, but doesn’t include an evaluator. You have to reload your page each time you want to query a new value.
  • Rhino is great for pure logic, but you can’t use it with anything that use a browser API. In fact, you can’t use it with anything that uses anything that uses a browser API. This means, for example, that you can’t use it with a library that uses Prototype, without writing some mock objects first.
 read more »

Readable JavaScript Values

Posted by oliver
Sat, 03/04/2006 - 01:15

One problem with JavaScript development is that the string representation of a value doesn’t tell you much about the value. For example, [null], [undefined], and '' all display as the empty string. [1,2}, [[1,2]], and [[1],[2]] all display as 1,2 (and so does "1,2"). And ({a: 1}), ({b: 2}), and new MySwankyNewObject() all display as [object Object].

If you use an IDE for development, this may not be a problem. Probably the IDE has its own string representation; even if it doesn’t, you can generally drill into objects by clicking on them. This doesn’t help those us of who prefer REPL development or printf-style debugging. When you display a debugging value (to the browser status line, to the alert() dialog, or to the Rhino console), you’d like some indication of what it actually is. And JavaScript doesn’t generally tell you, at least when the value is more complex than a string, number, or boolean.  read more »

Canvas with Text

Posted by oliver
Tue, 02/28/2006 - 07:13

The two times that I’ve used the WHATWG canvas element recently, I’ve wanted a canvas with string rendering. The most recent time that I’ve used the OpenLaszlo drawview class (which has substantially the same API), I’ve wanted string rendering too.

The graph in reAnimator is a drawview, but with text labels for the edges. And the graph and parse tree in the Graph and Parse tabs of reMatch both use WHATWG canvas for lines, but text for labels. (These tabs are only visible in Firefox, for now.)

TextCanvas.js implements the canvas context extended with labels, for DHTML. And “textdrawview.lzx” implements drawview extended with labels. They share the same API, so that I can write graphics libraries (such as graph drawing) that work with both DHTML and OpenLaszlo. That API is described here.  read more »