Rotates.org

November 28, 2009 - ColorShift 0.6

Sooner rather than later it seems, you can now download Rotates ColorShift 0.6 and bask in its amazingness.

The main change is how you set your selectors; instead of writing your own jQuery to target the elements you want to change, you feed rotColShiftOpts.cssTransforms with an array of objects. This is what Rotates.org uses:

[
	{
		selector: "a, h2, h3, h4, h5",
		styles: [
			"color"
		]
	},
	{
		selector: "#header, #searchsubmit",
		styles: [
			"background-color"
		]
	}
]

Actually it was a bit of a struggle, as I wanted to abandon the DOM-based approach to changing the CSS of every individual element, and go for a global stylesheet change. Easy you say? Just .append/.text a style element. Well, yes, in all decent browsers. Sadly, the IE family seems unwilling to let you tamper with the style element so easily, and jQuery (at the moment) has no elegant way around it. So out came the ‘Lew hacking pants’ with the following solution:

ieStyle = document.createStyleSheet();

$.each(rotColShiftOpts.cssTransforms, function(i, ttrans) {
	newColor = getColorWithOffsets(hue, saturation, brightness, ttrans.offsets);
	var tstyles = "";
	$.each(ttrans.attributes, function(i, ts) {
		tstyles += ts + ": " + newColor + ";";
	});
	tmpTransforms += ttrans.selector + "{ " + tstyles + " } ";
});

if ($.browser.msie) { // *sigh*
	ieStyle.cssText = tmpTransforms;
}
else {
	$("style[title='colshift']").text(tmpTransforms);
}

Anyway the result is that you a) get a better, easier to use syntax for applying the changes to page elements, and b) can be safe in the knowledge the styles will be applied to all elements on the page (even generated ones)  just like CSS should be. Enjoy!

- ColorShift update coming soon

I’ve been playing with various Twitter widgets for WordPress, none of which have been quite ‘right’, so I’ll be creating my own. This has also spurred me to update ColorShift, as the fail is now showing in the code, and it needs a more robust way of applying colours to all elements, including ones added after page load.

Look out for a new version of ColorShift in the next few days, along with possibly a new mini-project in the form of my own Twitter widget for WordPress – jQuery driven (of course), semantic, configurable, and with optional caching and API limit safety features.

November 17, 2009 - Perseverance pays off

Imagine having a web server that stores your objects and data just like a live app. Imagine being able to write in the same language on the server and on the client. Something this awesome has been a long time coming, but it’s finally here!

I’ve of course been playing with Persevere and absolutely loving it. Part of the big delay with ‘the Chaos remake’ has been the complexity of creating a robust way to get data from the clients to the server, and for the server to remember that data and be able to process it in the same way. Well now, thanks to this fantastic piece of kit, I can do all of that. Each server instance is a live JavaScript interpreter, with its own persistent object storage database – i.e. objects created are both accessible at any time, and saved.

What does this mean? Well, with the help of haXe (another brilliant tool) I can now write the code for the remake in one language, and ‘compile’ various parts of it to different platforms. I can write most of the game logic and other critical stuff and then have it work the same on the server as it does if it was just running on your own machine – and Persevere will make sure that it acts in that same ‘in-memory’ persistent way.

There are other projects on the go which I’m going to use as testbeds for Persevere – it’s not without possible issues, scalability being the big one at the moment, as one of my projects may end up being quite heavily used (one hopes anyway) and Java (the underlying tech behind Persevere) may not be up to that kind of task.

I can see Persevere being just the beginning of a whole paradigm shift for many parts of the internet into persistent object-based servers – it certainly doesn’t make sense with rich web apps to have to jump through all the current hoops and endure the inefficiences that go with the current ‘single shot’ model of web languages. Bring it on!

November 3, 2009 - Leaky pipes

Well, a tumultuous relationship with Yahoo Pipes has ended after a long struggle with various bugs, inefficiencies, annoyances and finally service refusal. There’s no doubt Pipes is a very useful and clever system, but it has some very serious downsides:

  • Caching – every pipe is rigorously cached, and updates are so infrequent as to allow bugs to go unspotted during testing, and suddenly rise after the fact.
  • Crap editor – I know YQL allows you to actually type out your stuff, but Pipes forces you to use its extremely buggy visual editor, which (among other things) fails to resize properly, does not allow copy and paste, frequently puts operators inside the wrong loop (and thus overwrites a painstakingly written item creator or whatever), seems to suddenly stop working at random – especially if one of your feeds is broken or returning malformed data, which results in ALL of your pipe, even unconnected nodes, breaking ingloriously.
  • Usage limits – despite the fierce caching, they still apply a fairly unsatisfactory usage limit, and without warning will shut down your pipes if they go over the limit.
  • Inefficient operators – sometimes you really have to go several times around the block to do very simple things, and you’ll quickly run into these issues.

All in all, I know Pipes is free and efficient, but upon my pipes being blocked because of a bug at my end which made too many requests, I had to quickly write my own PHP version to do the same job – and I found I had more control, it was on the whole an easier experience, and I have control over my own caching and debugging.

The people who use pipes are invariably developers – so as a word of warning: if you can do it yourself, take the time to do so, don’t rely wholely on third party services.