- ARCHIVE / JavaScript
- IE drops file uploads on the floor
On top of the whole X-UA-Compatible (for some obscure value of Compatible) debacle, last week gave me one more reason to hate Internet Explorer: the way it handles injection of file upload fields into the document. I was writing some code to allow an arbitrary number of files to be uploaded, one by one, through [...]
- Bringing “static” type-checking to JavaScript
It looks like my language to learn for this year is Java. Last year (well, tail end of 2006) is was Ruby and Rails, and I’m very much still learning as far as those are concerned. I also got heavily into JavaScript; I’d done a little jQuery before but 2007 was the year I really [...]
- Deriving the Y combinator
Before I start in on this: be aware I’m mostly writing this to force myself to understand something by writing it down. If you get anything out of it, consider it a bonus. I will be deriving Y() in JavaScrpit, and giving a version in Ruby.
After stumbling on this article on Raganwald last year (thoroughly [...] - Announcing Holly
After some discussion at work about how to manage JavaScript dependencies in our CMS, I decided to write a quick Rails plugin for doing just that. It’s called Holly, and it lets you use special comments inside script and CSS files to declare their dependencies. Whenever you use javascript_include_tag or stylesheet_link_tag, Holly inspects the dependencies [...]
- Natural-order sort in JavaScript
For your delectation and amusement in this new year: the shortest (and possibly slowest…) natural-order sorting method I could come up with:
Array.prototype.naturalSort = function() {
var p, q, valueOf = function(t) {
return isNaN(t) ? t.charCodeAt(0) :
Number(t) - Math.pow(2,32);
};
return [...] - JS.Class 1.0 hits the shelves
After much sweating, coding, and documentaion site-building, the 1.0 release of JS.Class is upon us. Thanks to the current edge version of PackR, I’ve managed to keep the filesize down but add boatloads of new features. I’ve tried to cram as much of the Ruby way into it as I can, with a pinch of [...]
- PackR won’t touch your $supers
Another quick update: PackR received an update today that means that when you use its :shrink_vars mode, it won’t minify any variables called $super. In Prototype, $super is used to implement inheritance and your class definitions will break if you change its name.
I didn’t really want to make PackR inconsistent with Dean’s original, but without [...] - Self-currying JavaScript functions
I’m telling you, this language keeps surprising me. You’ll need Prototype for this one.
Function.prototype.toSelfCurrying = function(n) {
n = n || this.length;
var method = this;
return function() {
if (arguments.length >= n) return method.apply(this, arguments);
return method.curry.apply(arguments.callee, arguments);
};
};
Make a simple function:
var adder = [...] - PackR gem now available
Update: the gem seems to be up on RubyForge now, so just gem install packr and you’re all set.
At the request of Aman Gupta (again!) PackR is now available as a gem. I’ve not got myself all set up on RubyForge yet, but in the meantime you can download the gem from my subversion repository. [...] - What are you doing with Sylvester?
Apparently some people are actually using Sylvester. Which comes as something of a surprise to me because I’ve had nobody (until today) email me or comment here about it at any length. It initially came out seven or eight months ago, and while I intented it to be a full 3D rendering environment, my day [...]