CMXtraneous

Right on the edge of useful

Of Towers Dark and Gunslingers Obsessed and the Ripple Effect

Posted Monday, June 20, 2005 9:33:54 PM by Jim Babbage

Jim Babbage

I just closed the back cover on the latest Dark Tower offering from Stephen King, Song of Susannah. Well, the latest offering that I've had the pleasure to read, anyway.

This Dark Tower series, starting with the Gunslinger oh so many years (yes, years) ago, has got to be some of the best work King has ever done. The not so merry band of characters has successfully transported me to Mid World and beyond every time.

In other words, I love these books. 

If you're not a King fan, because of what you think he writes, these books may be for you. It's not like the majority of his other work. This tale is many of the things his other books are not. That's not to slight previous writings - in most cases - but merely to state that this series is different.

I am - I happily admit - a fan. Have been ever since age 14, when I borrowed my Dad's copy of The Stand, written by some guy I never heard of at that point in my life. That book blew me away. I have at least two copies of The Stand in my library. Different editions; the original (well, a reprint, but you get my drift) and the uncut version.

I'm also halfway through his non-fiction piece, On Writing.  I am in the middle of another sci-fi book, too, World Without End by Molly Cochran and Warren Murphy, and at least one software related text.

Did I mention I am a book nut? 

I like the idea of other worlds/possibilities/dimensions. It stuns me at times to realize how one single choice can put you on a path or change your direction in life. For several reasons, I need to or like to think that different versions of  me - of everyone - make different choices and travel paths that the me here didn't make.

I guess I'm getting older, 'cuz I find myself thinking more often of how I got to where I am professionally, personally and emotionally. The choices - some on a whim, some definitely not - I made which put me here, now. The ripple effect one decision can make on your life is astounding.

As some of you know my original career was/is that of a professional photographer. I backed into that career (or it snuck up on me) by choosing to go to Journalism school. That decision was one of those on a whim choices I'm talking about. I was fast approaching the end of Grade 12, well past the deadline for choosing a college, when I decided I didn't want to spend another year in high school (in Ontario, back then, we had Grade 13). I loved Theatre Arts. I starred in three productions at the school from Grades 10 - 12) and seriously thought about becoming an actor.

Over that time I also seriously thought of becoming a teacher.

Then I just seriously thought.

While I might have loved acting, I knew somewhere inside it was not a logical or financially sound career choice for me.

While I greatly respected many of my teachers - especially my Theatre Arts teachers and one particular math teacher who actually managed to teach me something about math - I didn't see myself surviving another year in high school, which was needed for University. And for that matter, I didn't see myself surviving University and then Teacher's College, either.

While I didn't love English, I enjoyed it well enough and my marks were pretty good. I liked to write - especially my own grand literary works of speculative fiction. I figured a career where someone paid me to write wouldn't be so bad. I decided to just stop into the Guidance office and ask what my chances were of being accepted in the Journalism program at Centennial College.

Somehow, the counsellor managed to get me an interview and that autumn, I was learning all about how to be a journalist.

The two most valuable things I learned in my two (of three) years at college were:

  • I did not want to be a journalist.
  • I loved taking pictures. 

I left after the second year and had no real regrets.

OK, the diploma would have been nice.

I applied for a job as a layout artist for a start up fashion magazine/model agency. I ended up becoming one of their photographers. The magazine never materialized, but I shot a lot of wanna-be fashion model portfolios. From then on, I was stuck in the groove of being a professional photographer. Being mostly self-taught, I think I've done alright for myself in that area.

Drop a stone (make a choice) in the water (in your life). Ripples in the water. Ripples in time.

I started out wanting to be a writer, ended up being a photographer (and was much happier for it). Years later, my photography career and my irregular contact with my old photography teacher led me to doing a few guest lectures back at - you guessed it - Centennial College.  Guest lectures led to teaching a photography course in - ironically - the Journalism program.  At that point high school seemed so very close and yet so very far away.

The Internet tapped my photographic career on the shoulder in the mid '90's. Before I knew it, I was building a web site for the photo studio I worked in.

My interests grew to include the Web and imaging along with photography, writing and teaching. They melded, all fitting together, like pieces of a puzzle.

Then one day a few years back,  I heard about some conference called TODCON. I always wanted to attend MAX but just didn't have the cashola for that investment. TODCON fit the bill. It was something I could afford - mostly because I could convince the studio and the college that it would be beneficial to them to help me attend.

And it was - is - beneficial, to them and to my career. I learned a great deal. I networked a little. My networking strategy was a cunning combination of two tactics: standing around groups of people I didn't know and nodding, smiling and laughing at the right points. At other times looking like a lonely, forlorn Candian so people would feel sorry for me invite me to lunch. Hey, it worked - I had lunch with Massimo Foti and Angela Buraglia that first year.

Seriously, I am shy when in new surroundings. Not as much as I used to be, but still a bit quiet around people I don't know.  I live vicariously through my collect of vibrant shirts.

I also remember bugging the hell out of Ray . . . I guess over time I made an impression.

And, oh man, the BOOKS! 

I have never missed a TODCON. I hope I never do. 

Years of attending and helping out where I could led to speaking engagements at TODCON, which in turn led to being offered a place as a partner right here on CMX.

So now I write, I teach, I take pictures and design websites for a living. I speak at a very cool event. I meet a great many talented people, many of whom I consider good friends. Life is rarely dull.

Full circle, man. Full circle. The interesting thing about ripples in water is they start small and grow larger. The result of one stone (decision) grows in size, spreading to cover a larger and larger area (experience).

Pretty cool when you think about it. 

Category tags: On the Personal Side

SQL function to chop a field by number of words

Posted Monday, June 20, 2005 6:37:59 PM by Tom Muck

Tom Muck

I was prompted by a question on the CMX forums today to finally break down and write a function to return a number of words from a database field, which I've been meaning to do for a long time. There are script examples on the web for ASP and ColdFusion code to truncate a specific database field to a certain number of words (split at the word rather than mid-word, as the LEFT function does), but there is no easy way to do it in SQL, unless you use a loop. The following function will truncate any field to a specific number of words. Pass in the string you want to parse, and the number of words to return.

CREATE FUNCTION fnGetNumberOfWords (
  @stringToSplit varchar(8000),
  @numberOfWords int
)

RETURNS varchar(8000) AS

BEGIN

DECLARE @currentword varchar(8000)
DECLARE @returnstring varchar(8000)
DECLARE @wordcount int
SET @wordcount = 0
SET @returnstring = ''
SET @currentword = ''
SET @stringToSplit = ltrim(rtrim(@stringToSplit))
Declare @index int

WHILE @wordcount < @numberOfWords AND len(@stringToSplit) > 0
  BEGIN
    Select @index = CHARINDEX(' ', @stringToSplit)
    if @index = 0
      BEGIN
        SELECT @currentword = ltrim(rtrim(@stringToSplit))
        SELECT @wordcount = @numberOfWords
      END
    else
      BEGIN
        IF (len(@stringToSplit) - @index > 0) BEGIN
        SELECT @currentword = ltrim(rtrim(LEFT(@stringToSplit, @index-1)))--the new shortened string
        SELECT @stringToSplit = RIGHT(@stringToSplit,LEN(@stringToSplit) - @index) -- the rest
      END
    END
  SELECT @returnstring = @returnstring + ' ' + @currentword
  SELECT @wordcount = @wordcount + 1
END

SET @returnstring = LTRIM(@returnstring)
RETURN @returnstring

END

Call it like this:

SELECT dbo.fnGetNumberOfWords(MyField, 10) FROM mytable

(returns first 10 words from MyField)

The advantage to doing it in the database rather than on the web page, is that you are only returning a small portion of the field to the web page, rather than the entire field. This can speed up the query. A few preliminary tests show that the smaller number of words you return, the quicker the query will execute. In other words, if your query returns a field that can contain up to 8000 characters in it (like a blog entry, for example) and you only need the first 50 words for a summary, the query to return the 50 words will be faster than a query that returns the whole field. Also, your scripted page will execute faster because it is simply displaying the field and not performing any further logic, looping, or parsing on the field.

I talked about user-defined SQL functions in one of my articles at Community MX as well:

Using CSV Strings in SQL Server: Part 2

Note that the function does not work on text or ntext data types. I hope you find it useful.

Category tags: ColdFusion, Community MX, Dreamweaver, SQL Server