jsFiddle is a great tool for quick JavaScript prototyping. While it’s possible to use your browser’s console log to preview bits and pieces of output, I was looking for a cleaner way to do this, using just the jsFiddle panes. I’ve come up with a simple way to add a logging facility to the Result pane if you are using jQuery.
Author: Wayne Koorts
JavaScript snippet: Remove base URL from link
I needed this function this morning so I thought I’d share it in case someone else does too.
function RemoveBaseUrl(url) {
/*
* Replace base URL in given string, if it exists, and return the result.
*
* e.g. "http://localhost:8000/api/v1/blah/" becomes "/api/v1/blah/"
* "/api/v1/blah/" stays "/api/v1/blah/"
*/
var baseUrlPattern = /^https?:\/\/[a-z\:0-9.]+/;
var result = "";
var match = baseUrlPattern.exec(url);
if (match != null) {
result = match[0];
}
if (result.length > 0) {
url = url.replace(result, "");
}
return url;
}
It’s Not That Bad…
It’s taken nearly a year for me to become angry inspired enough to blog again. The culprit this time is ASP.NET poster boy Scott Hanselman. I’m only mentioning him and will be linking to the inflammatory material in question because nobody reads my blog; he certainly doesn’t need the publicity.
Steer Well Clear
This morning a friend told me about this article, all about a new advertising campaign run by Steers, a South African fast food chain. The article is all about the gross misuse of grammar in the campaign and musings on corporate irresponsibility.
I’d like to take this opportunity to share my thoughts on the humble, often-neglected, apostrophe and the evolution of language.
Gentle Editing
Like many programmers, I’ve come to love Stack Overflow and the rest of the Stack Exchange network. Its unique Wiki / Blog / Forum blend creates a fantastic platform for knowledge sharing.
Thanks to its Wiki-like editing capabilities, quality sticklers like myself can get stuck in and help to smooth out some of the rough edges of the content base.
Unfortunately we geeks sometimes allow our egos to get the better of us, resulting in reasonably common, dreaded, edit wars. To avoid these, I’ve come up with what I feel is a very gentle and respectful editing style which I’d like to share with you today. My edits always take a fair bit of time, but I feel it’s worth the investment in the interests of the greater good.