Shaun Mccran

My digital playground

30
O
C
T
2009

Movember - Prostate Cancer Charity month - time to grow a tash

I don't normally 'do' charity, unless its animal charities as I think they get the roughest deal. However this year I am growing a moustache for Movember. I have decided to put down my razor for one month (November) and help raise awareness and funds for mens health, specifically prostate cancer.

What many people don't appreciate is that one man dies every hour of prostate cancer in the UK, more than 35,000 men will be diagnosed this year and that prostate cancer is the most common cancer in men in the UK. Facts like these have convinced me I should get involved and I am hoping that you will support me.

To donate to my Mo, you can either:

  • Click this link http://uk.movember.com/mospace/26347/ and donate online using your credit card, debit card or PayPal account
  • Write a cheque payable to 'The Prostate Cancer Charity - Movember', referencing my Registration Number 26347 and mailing it to: Movember - The Prostate Cancer Charity, First Floor, Cambridge House, Cambridge Grove, London, W6 0LE.

Movember is now in its third year here in the UK and, to date, has achieved some pretty amazing results by working alongside The Prostate Cancer Charity. Check out further details at: http://uk.movemberfoundation.com/research-and-programs.

If you are interested in following the progress of my Mo, click here http://uk.movember.com/mospace/26347/. Also, http://uk.movember.com has heaps of useful information.

Thanks Shaun

23
O
C
T
2009

Pop quiz! Create an object of items and counts from a paragraph of text

I was digging around in some old code the other day, having a 'server' tidy up, and I came across a pair of code challenges that a company set for me a few years back. They were to try and gauge how you approach a problem, and see if you are at least familiar with the cfml code base. I quite like Ray Camden's Friday challenge idea, so in a blatant homage, I'm posing these two code challenges in the same way. This one this week, and a numeric one next week.

The challenge:

Take a paragraph of text and return a data object(whatever format you want) of the words in it, and their frequency. This is the example paragraph given.

view plain print about
1The old lady pulled her spectacles down and looked over them about the room;
2then she put them up and looked out under them. She seldom or never looked THROUGH
3them for so small a thing as a boy; they were her state pair, the pride of her heart,
4and were built for "style," not service -- she could have seen through a pair of
5stove-lids just as well.

The type of object and the method of producing it are entirely open. You an choose how to handle punctuation and text casing.

I've written a test form, and a solution myself, but it is always interesting to see how different minds approach the same problem.

I'll give it a while, and then post my solution here.

Update Here is a CFC that I put together to solve this. It strips out the punctuation, and creates a Structure of the words, and their count.

view plain print about
1<cfcomponent displayname="Parser" hint="Parses a set of text" output="false">
2
3    <cffunction name="parseText" hint="Parses a passed in section of text, returns a struct of values" access="public" output="true" returntype="Struct">
4        <cfargument name="rawString" required="true" hint="Text to parse">
5
6        <!--- list items to remove --->
7        <cfset var itemsToRemove = '-,;,",.'>
8        <cfset var parsedString = structNew()>

9        <cfset var part = "">

10
11        <!--- Clean the punctuation out of the arg --->
12        <cfset var cleanedString = ReplaceList(arguments.rawString, itemsToRemove, " ")>
13        <cfset cleanedString = lCase(Replace(cleanedString, ",", " ", "ALL"))>
14
15        <cfloop list="#cleanedString#" index="part" delimiters=" ">
16            <cfif NOT StructKeyExists(parsedString, "
#part#")>
17                <!--- Add to struct --->
18                <cfset parsedString[part] = 1>

19            <cfelse>
20                <!--- increment count, get it and add one --->
21                <cfset parsedString[part] = parsedString[part] + 1>
22            </cfif>
23        </cfloop>
24
25        <cfreturn parsedString />
26    </cffunction>
27
28</cfcomponent>

27
A
U
G
2009

My friend has launched his Photography site

I've got a Coldfusion developer (part time photographer) friend who has just finished his photography site. It's up now at http://www.tonybaileyphotography.com/.

He's also been invited to provide a photo for the site http://www.todaysphoto.org. It is a night shot of the Bridge over the Severn Estuary,crossing from England to wales.You can view it here.

Also serves as a remind to me that I need to get out with my Canon more!

30
J
U
L
2009

Displaying raw html onscreen using the Example html tag

Ever needed to display an example block of HTML code in a web based document or regular web page?

I had just that requirement recently, so thought I'd have a dig around. It is one of the smallest html tags I've found, it is the example tag.

view plain print about
1<xmp> html code</xmp>

It works very much like the 'pre' tag in the way that it displays whatever it contains without any sort of formatting, in its raw state. Except that this also display html, rather than interpreting it, it displays it exactly as is.

Nothing revolutionary, but a nice surprise and handy for code samples etc.

_UNKNOWNTRANSLATION_ /