Archive for the ‘Railo’ 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?

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 »

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