Archive for the ‘ColdFusion’ Category

Find the closest in a list of numbers

Saturday, April 26th, 2014

For a while now I’ve been working on a core set of functionality that I include with every application. In fact, my applications extend a core app that contains a whole bunch of commonly used functionality – but that’s a whole other post.

I’d intended to blog about some of the components I’ve been writing as I go along, but as is so often the case I find myself moving onto new work before I’ve sat down to write about the last.

Today, I needed to pass a number to a function and return the closest number in a given list.
So for example, a list of ‘10,20,50,100,200,1000’ and a value of 42, should return 50.

It’s a simple requirement, but Google returned nothing & the mighty Ben Nadel hadn’t written a comprehensive post on how to do it along with speed tests and examples involving hot girls; so I wrote a function and added it to my ever increasing library.

As it’s small, I thought I’d share… in doing so, I realised I’ve not updated this site in way too long – so for this I apologise.

Here’s what I came up with – hopefully it’ll save someone a bit of time:

Posted in CFKrypton, ColdFusion, Railo | Comments Off on Find the closest in a list of numbers

Lock wait timeout exceeded with ColdFusion & MySQL – Checked yer logs?

Sunday, March 31st, 2013

I just spent some time diagnosing an issue with inserting records into a MySQL database and I eventually tracked it down to a gotcha I think a lot of other people may run into.

The code in question does some fairly simple things – inside a <cftransaction> it’ll insert a record into a table, read the record back and insert a record into a second table with contents from the first record.

Easy, right? Except every time I tried it, I’d get a timeout with the following error:
Lock wait timeout exceeded; try restarting transaction
Inserting the records manually worked fine, but not from CF.

After searching through the MySQL logs, I noticed that a second connection was made half way through the transaction – the remaining query would then time out and the transaction would roll back.
What I discovered is this:

<cfquery datasource="yourDatasource">

is treated as a different connection to

<cfquery datasource="yourDatasource" username="" password="">

Generally I won’t include usernames and passwords in my cfquery statements, but I’m connecting to a library that does by default. I’ve found that leaving the authentication fields blank will connect fine using those specified in the datasource, however it seems that MySQL considers it a different connection which will cause a problem in a transaction.
I’m running Railo 4 – the behaviour may differ on ACF.

So there you have it. A great argument for encapsulation and a nicely configured datasource object.

Posted in ColdFusion, Railo | Comments Off on Lock wait timeout exceeded with ColdFusion & MySQL – Checked yer logs?

Dynamically resize images with ColdThumbs

Monday, March 12th, 2012

A few days ago I was coding up a WordPress theme for a client who intended to move away from WordPress.com.
One thing I noticed is that on the WordPress.com installation, images were dynamically resized by adding a parameter after the image file extension.
i.e. http://domain.com/images/an-image.jpg?w=400
Since many of the posts linked to images in this way, I had to find a way to replicate it into the WordPress installation on the local server. A quick Google search and I discovered ‘TimThumb‘, a php script for dynamically resizing images, very popular amongst WordPress theme developers.

Within a few minutes, I had the functionality I was looking for.
‘Very cool’, I thought to myself… So why can’t I do this in ColdFusion?

Enter: ColdThumbs!

Inspired by TimThumb, ColdThumbs is allows you to dynamically resize an image (local or external) to your desired dimensions.
The script will automatically create a cached version of your resized image and return the image as content.

I developed this as a bit of fun one Sunday (yeah, that’s how I roll) and have put it up as my first project on RIAForge. It’s working great for me, but I’d love to hear feedback or feature requests from anyone using it.

Check out the ColdThumbs page for full details.

Posted in ColdFusion | Comments Off on Dynamically resize images with ColdThumbs

Integrate WordPress into your ColdFusion app

Thursday, January 13th, 2011

Lately I’ve been working on a few ColdFusion apps that require a comprehensive blog system. While I could easily install Mango Blog or Blog CFC, nothing really rivals the functionality of WordPress when it comes to blog apps – but of course, WordPress is a PHP based system.

Installing WordPress alongside a ColdFusion app isn’t too difficult, but I need to customise the blog so that it looks identical to the rest of the site, and allow the user to switch seamlessly between the two.

This level of integration requires two main bits of functionality. Firstly I need to use ColdFusion to connect to the WordPress database and pull out articles and comments for use in summary blocks around the rest of the site, and secondly I need to be able to embed CFML templates directly into the WordPress blog to generate headers and footers whilst keeping any session based information such as login status, cart contents etc. – Essentially I need a CFINCLUDE equivalent for PHP.

(more…)

Tags: , ,
Posted in ColdFusion, Railo, Website Development | 19 Comments »

Cache and display multiple Twitter feeds in ColdFusion – CFC

Friday, November 19th, 2010

I’ve worked on a few sites recently that have required Twitter feeds to be pulled in and displayed on the homepage.
Thanks to the awesome <cffeed> tag this is a relatively easy task, but I’ve noticed a bit of an overhead when pulling the data in from Twitter’s servers.

I had a look around and came across this post by Simon Bingham, showing how to cache the results of a Twitter feed in the Application scope.

This worked well, but I needed to be able to pull in both outgoing tweets (using the Twitter ID) and incoming tweets (using a search string). This meant not only updating the CFC to take both types of argument and act accordingly, but also to allow mutiple feeds to be cached.
Building on Simon’s original, I’ve created a new CFC that does just that, and even has a bit of error handling for good measure.

(more…)

Tags:
Posted in ColdFusion, Railo | 2 Comments »

If ColdFusion is dead, it’s Adobe that killed it.

Wednesday, September 15th, 2010

(Or, ‘Controvertial ColdFusion post #34124′)

I’ve been using ColdFusion happily for the last 6 years. I can honestly say that if it weren’t for the ease of learning ColdFusion, and the instant gratification to be gained from rapidly developing apps that interact with databases, I’d have never found my way into backend development.

Like any language however, ColdFusion is not without its problems. We can compare functionality until the proverbial cattle return to their domiciles, but what I’d like to talk about is the culture of elitism that surrounds ColdFusion.

‘Elitism?!’ I hear you cry, ‘But ColdFusion is so easy to pick up, and the community is so friendly and welcoming! That’s hardly elitist, is it?’.

Yes. You’re right… but what I’m concerned with is the difficulty ColdFusion developers face in the environment in which they work. Adobe have done a very good job of making ColdFusion inaccessible to the masses by focussing on enterprise clients, inadvertently turning ColdFusion into quite an exclusive club.
Don’t believe me? Reel off the names of some well known ColdFusion celebrities… Ray Camden, Ben Nadel, Ben Forta, Et al. I’ll bet if you’re a ColdFusion developer, you’ll know who those people are. You’ll have read their blog posts, be aware of projects they’ve done. You’ll probably be able to list 10 more without too much trouble…
Well, you shouldn’t be able to do that – because the list should be huge. If we were talking about PHP, there’d be maybe 5,000 people in that list. In ColdFusion there’s maybe 20.

Let me explain… (more…)

Posted in ColdFusion, Railo, Servers, Website Development | 17 Comments »

Tutorial: Setting up a production Windows 2008 server with IIS7 & Railo

Tuesday, June 29th, 2010

Prologue:

In which Gary explains his new found appreciation for anyone who calls themselves a sysadmin.

I’m not a sysadmin. I like to make websites. It’s what I do, what I’ve always done.
Dealing with servers is the un-planned love child of my long term affair with website development. A horrid child that demands constant attention and gives nothing back in return.

In the past, I would point clients in the direction of a decent web host and let them get on with it, but as it turns out these clients would still phone me as the first point of contact when their servers went down, making me a mediator between them and their hosts. Frankly, I figured if I’m spending my time doing this anyway, I may as well get paid into the bargain.

Well, after four years of hosting client’s websites I can quite categorically state that sysadmins have one of the most difficult jobs imaginable. Anything can go wrong, at any time. Running a tight system involves research, dedication, and genuine enjoyment of high level tinkering.

If I’m ever in a position to employ a sysadmin, they will be treated well. I will make them tea. And cake. And give them sympathy.
Recently, after a long and gruelling battle with the most unreliable hosting company I’ve ever used, I finally took the plunge and set up my own Windows VPS using IIS7 & Railo. (more…)

Tags: , , ,
Posted in ColdFusion, Railo, Servers | 4 Comments »

Combatting misinformation in web design

Thursday, March 11th, 2010

I received an email from a client recently, informing me that they have hired someone to redevelop their entire website in php, as they have been informed by their SEO company that ColdFusion is ‘bad for search engines’.

Frankly, I think it’s astounding that any SEO company could make such an assertion, anyone in the industry would immediately understand just how ridiculous this statement is – but unfortunaty our clients are not experts and can only make their decisions based on the advice they receive from the people who claim to be. My clients in this case have made an informed choice, based on patently false information…

So I’d like to state definitively: ColdFusion has nothing whatsoever to do with SEO… Neither does php, asp, ruby, python, perl, or in fact any back end language at all…
(more…)

Tags: , ,
Posted in ColdFusion, General, SEO, Website Development | 6 Comments »

Coldfusion, IIS7, Plesk and 401 Authentication

Thursday, July 16th, 2009

While installing Coldfusion 8 on Windows Server 2008, I came across a problem that I simply couldn’t find an answer for anywhere on the interwebs. Now, some three hours later I’ve stumbled across the solution and thought I’d blog about it in an attempt to save others the headache.

The Problem:

You have a fresh install of Windows 2008 server running Plesk Control Panel.
You innocently download and install a copy of ColdFusion 8. The installation goes fine and you can access the ColdFusion administrator with no problems…
However, when you try to access a .cfm page on any other site, you’re greeted with a login prompt asking for authentication details. You’ll also find that your Plesk URL does the same thing.
In fact, any page on any site other than the default (which is where your ColdFusion Administrator is installed) is now asking for authentication, and of course returning a 401 error when you are unable to supply the correct login details.
(more…)

Posted in ColdFusion, General | 8 Comments »

About

Simian Enterprises is the trading name of Gary Stanton, a freelance web developer working by the sea in Brighton, UK. Gary's been creating websites since 1996 and still loves it. Read more

Contact

Gary Stanton

Email:

Tel:
01273 775522

Twitter

No public Twitter messages.

Delicious Feed

Website Design & Development