Songs for the Cure 2010

Last year, I was proud to be part of the inaugural Indie Music Cancer Drive. Along with a whole lot of very talented artists, I contributed music to a compilation album, “Songs for the Cure”. All the proceeds from the sales of this album went to the American Cancer Society.

Songs for the Cure 2010

This year, I am once again contributing. I just finished work on the track I will be contributing, so I thought it high time I let everyone know about this. Josh Whelchel, the organiser of the drive (and a fantastic musician to boot), has set a target of $10,000 for this year. If you donate $25 or more, you receive a physical copy of the (two disc!) album; otherwise, you receive the album digitally.

Here’s the official media release:

Indie Music Cancer Drive to Release Songs for the Cure ’10 Album

Twenty-eight artists join together to raise money for the American Cancer Society and aim to raise $10,000.

Cincinnati, OH, January 24th, 2010. – The Indie Music Cancer Society will release it’s 2010 compilation, Songs for the Cure ’10 on March 1st, 2010 and forward 100% of all donations and profits to the American Cancer Society through its Relay for Life event held on April 23rd, 2010 at the University of Cincinnati. The album will feature music from over twenty-eight (28) diverse artists, including Select Start, big giant circles, Alec Holowka, Two Seconds Away, Jay Tholen, Josh Whelchel, Renee Winter, and others. The organization is currently accepting donations, and all donors of $25 or more before MARCH 1, 2010 will receive a free physical copy of the album. Supporters with $10 or more will receive a free digital copy. Genres represented include Pop, Rock, Alternative, Chiptunes, Instrumental, Opera, Classical, Avant-Garde, Jazz, Fusion, and many others. The organization raised over $6,000 for the event last year and is still forwarding profits from last year’s album, available on iTunes, Amazon, and others. A full list of artists can be found at the Songs for the Cure ’10 website at http://www.cancerdrive.org. The fundraiser aims to raise $10,000 by April 23rd, 2010, preceding a digital release of the album to iTunes, Amazon, CDBaby, and other retailers. Donations are accepted through http://www.cancerdrive.org.

For more information please contact:

JOSH WHELCHEL
(513) 549-2336
http://www.cancerdrive.org

So there you have it. And for good measure, here’s the promotional video:

Another new theme

I was never really happy with my previous 2010 theme, so I’ve gone and done a completely new one.

This new one makes extensive use of CSS3 properties, such as gradients and shadows. It looks best in Firefox >= 3.6,followed by Safari >= 4, then Chrome >= 4, Opera >= 10, and IE >= 8. Theoretically, Firefox and Safari/Chrome support the same level of features, but the webkit gradient syntax is absolutely awful. It’s confusing, needlessly complex, and poorly thought-out, in my opinion. Contrast the following two lines:

background: -moz-linear-gradient(top, #111, #333);
background: -webkit-gradient(linear, left top, left bottom, from(#222), to(#333));

See what I mean?

Gecko (Firefox), Webkit (Safari), and Trident (IE) rendering.

Clean Word markup

When writing a web-app that accepts formatted input from users, you’ll often find that they will copy and paste text from Microsoft Word. Unfortunately, Word fills the markup with lots of unnecessary and unwanted muck. To clean this all up, I wrote the following function (directly implemented on the String prototype below):

String.implement({
	sanitiseWord: function() {
		var s = this.replace(/\r/g, '\n').replace(/\n/g, ' ');
		var rs = [];
		rs.push(/<!--.+?-->/g); // Comments
		rs.push(/<title>.+?<\/title>/g); // Title
		rs.push(/<(meta|link|.?o:|.?style|.?div|.?head|.?html|body|.?body|.?span|!\&#91;)&#91;^>]*?>/g); // Unnecessary tags
		rs.push(/ v:.*?=".*?"/g); // Weird nonsense attributes
		rs.push(/ style=".*?"/g); // Styles
		rs.push(/ class=".*?"/g); // Classes
		rs.push(/(&nbsp;){2,}/g); // Redundant &nbsp;s
		rs.push(/<p>(\s|&nbsp;)*?<\/p>/g); // Empty paragraphs
		rs.each(function(regex) {
			s = s.replace(regex, '');
		});
		return s.replace(/\s+/g, ' ');
	}
});

If you’re not using MooTools, the function will look something like this:

String.prototype.sanitiseWord = function() {
// function body here...
};

Usage

var s = "(some awful Word markup)".sanitiseWord();

In one of the tests I ran, the input went from around 7000 characters to just 700.

Example

Some of the regular expressions I used were adapted from C# ones in a post by Jeff Atwood.

Quicksort an array of objects

Often, you will need to sort an array of objects in Javascript. The inbuilt sort() function can’t do this, but here is a Quicksort implementation for doing just this.

Parameters

array The array to be sorted. (See below for an implementation on the Array Native itself, which makes this variable unnecessary).

key The key to sort by. Make sure every object in your array has this key.

Examples

var objs = [
	{fruit:"cherry"},
	{fruit:"apple"},
	{fruit:"banana"}
];

console.log(objs.sortObjects('fruit'));
// Logs [{fruit:"apple"},{fruit:"banana"},{fruit:"cherry"}] to the console

The code

sortObjects: function(array, key) {
	for (var i = 0; i < array.length; i++) {
		var currVal = array&#91;i&#93;&#91;key&#93;;
		var currElem = array&#91;i&#93;;
		var j = i - 1;
		while ((j >= 0) && (array[j][key] > currVal)) {
			array[j + 1] = array[j];
			j--;
		}
		array[j + 1] = currElem;
	}
}

Implemented on the Array native:

Array.implement({
	sortObjects: function(key) {
		for (var i = 0; i < this.length; i++) {
			var currVal = this&#91;i&#93;&#91;key&#93;;
			var currElem = this&#91;i&#93;;
			var j = i - 1;
			while ((j >= 0) && (this[j][key] > currVal)) {
				this[j + 1] = this[j];
				j--;
			}
			this[j + 1] = currElem;
		}
	}
});

Words I have invented

Here are just two of the words that I have invented to fill gaps in the English language. Adopt, disseminate, and promulgate them!

Spanxiety cf. spangst, spanxious

The fear of being punished; trepidation at the thought of retribution for past transgressions.

Little Jimmy, having been seen stealing the cookies, was now feeling quite spanxious.
I suffered a bout of spanxiety at the thought of what she would do to me.


Illigiterate cf. illigiteracy

Children born out of wedlock who lack basic reading and writing skills.

With the advent of widely-available contraceptives and education, illigiteracy has fallen in Australia.
Illigiteracy Venn Diagram

Camping: June 2009

Well, Ariel and I have just returned from a weekend away at Dwellingup, camping. How was it? First and foremost, it was cold. Bitterly cold. Notwithstanding the sub-arctic conditions, however, it was absolutely fantastic.

The Murray River is beautiful, and we were camped no more than fifty metres away from it. We camped in the “Stringers” area of the Lane Poole Reserve, and managed to wrangle probably the best camping site in the entire park — secluded, equipped with a fire pit, and quiet.

As you can see from the photos below, our two primary concerns were a) exploring the banks of the river, and b) fire. When it’s so cold at noon that you can see your breath, a fire is a wonderful thing.

 

(Click on an image for a larger view)

The amazing Regret Index

Ryan North, of Dinosaur Comics fame, has crafted an awesome little webapp: The Regret Index. Essentially, you vote on whether or not you regret certain things. You can even add your own regrets or search for regrets.

Most of them aren’t particularly serious, and a lot of them are kinda fun. It’s worth having a browse through the archive of regrets, looking at the votes, and reading the comments people have left. Some of my favourite ‘regrets’ on the site include

  • Eating a kitten just to prove you’re evil
  • Supergluing your foot to the bathroom floor
  • Constantly fearing regret
  • Starting to think all these questions are addressing you specifically

Check it out — it’s well worth a look.