Twitter API not showing Retweets FIX... that actually works this time!!!

We previously had the following code on a site to show the latest twitter post:

(remove _ from tagname!)

This worked fine, apart from if we posted a retweet - in which case, we just got an empty response from the API.

It turns out that the URL we were using, was for an older version of the API - updating to the newer version of the API fixed this issue:

Blog back online.

Sorry folks for all the errors you've been seeing when attempting to access this site.

I missed an email from the previous hosting provider announcing that the server the site was previously hosted on is being taken offline.

The site has now been moved to a new server - please let me know if you see any issues.

Thanks,

Dan.

CSS Parsing ColdFusion Function

Here's a function I knocked up to retrieve a specified CSS property from within a specified CSS Selector:

<cffunction name="GetCSSProperty" access="public" output="false" returntype="any" hint="I attempt to find and return a specified CSS property contained within a specifed CSS selector">
   <cfargument name="CSS" type="string" required="true" hint="CSS to Process">
   <cfargument name="Selector" type="string" required="true" hint="Selector to locate">
   <cfargument name="Property" type="string" required="true" hint="CSS Property to retrieve">
   <cfargument name="DefaultValue" type="string" required="false" default="" hint="Default value if not found">

   <cfscript>   
      var local = structnew();
      
      local.MatchingSelectors = REMatch("[^}]*#arguments.Selector#[^{]*{[^}]*#arguments.Property#[\s]*:[\s]*([^;}]*[^}]*})",arguments.css);
      if (arraylen(local.MatchingSelectors))
      {
         local.relevantSelector = trim(local.MatchingSelectors[arraylen(local.MatchingSelectors)]);
         local.FindValue = refind("{[^}]*#arguments.Property#[\s]*:[\s]*([^;}]*)",local.relevantSelector, 1, true);
         local.pos = local.FindValue.pos[2];
         local.len = local.FindValue.len[2];
         local.cssValue = trim(mid(local.relevantSelector,local.pos,local.len));
      }
      else
      {
         local.cssValue = arguments.DefaultValue;
      }

      return local.cssValue;
   </cfscript>      
</cffunction>

This function will attempt to return the specified property as defined in the last CSS definition which contains the specified selector. This does mean that it will potentially return false matches against more specific selectors - e.g. searching for font-size property within td.gridDataCell would return the value for the button (8px), even though more accurately the previous less specific value (10px) should have been returned.

td.gridDataCell {font-size:10px;}
td.gridDataCell button {font-size:8px;}

I have a particular use case for this functionality for parsing CSS used to control formatting of dynamically generated HTML emails, and convert it to HTML which is more compatible with Outlook 2007 (i.e. HTML Properties rather than CSS :-/) where I already know that no complex cascading rules have been defined - but if need be additional functionality could be added to parse the selectors within local.MatchingSelectors, and remove any matches which only match partially.

Outlook 2007 ignoring CSS within an HTML email due to 2 semicolons (;;)

Getting HTML emails looking good in Outlook 2007, is a relentless task at the best of times, but this one really caught me out...

The system I was debugging is used for creating and sending Email Marketing campaigns.

When creating a campaign, the system allows you to pick a template, - which selects a CSS style sheet which gets embedded into a style tag at the top of the email.

With one particular template, only around 10% of the styles appeared to be getting applied to the email - most of the email was just using the default styles.

When investigating, I noticed that all the CSS up to a particular point in the file (about 10% of the way through) was being applied, and the rest was being ignored.

This line caused the problem:

color:#FF9835;;

All CSS after the double semicolon was ignored.

The strange thing is, the CSS file validated successfully using the W3C validation service...

Interesting feature...

How to call a Web Service from CF7 using Client Certificate based ("Bilateral") authentication (Win)

If you have to call a web service from ColdFusion 7 - and the destination web service enforces bilateral SSL authentication (i.e. the caller has to supply a client certificate to prove who they are, as well as the destination supplying a server certificate to prove who it is...) - then the options, in descending order of preference are:

  1. Check / ask really nicely / beg / etc. to see if there is a way of calling the web service without passing a client SSL certificate
  2. Use CF8 (or later) - I believe that you will still need to do the SOAP generation by hand, as cfobject / cfinvoke do not appear to allow a client certificate to be set - but you can use cfhttp and specify the clientcert and clientcertpassword attributes - which avoids having to use the WinHttp.WinHttpRequest COM object as shown below.
  3. Use the WinHttp.WinHttpRequest COM object as shown below...

ColdFusion (when running on windows) allows (and has allowed for several versions) COM objects to be called from within CF code, using the CFOBJECT tag or CreateObject() function.

Built into the following versions of windows, is the WinHTTP 5.1 COM object:

WinHTTP 5.1 is available only with Windows Server 2003, Windows XP with Service Pack 1 (SP1), and Windows 2000 Professional with Service Pack 3 (SP3). (I suspect that it may also be available in Windows 2008)

This provides similar functionality to CFHTTP - but at a lower level.  In particular it allows a client certificate to be specified, using the SetClientCetificate function.

This is not as simple as it seems - where as in CF8 using CFHTTP you just have to specify the physical location of the client certificate file - the WinHttp object requires that the client certificate is first imported into a certificate store - and then the reference to the certificate provided to the SetClientCetificate function:

ClientCertificate [in]

Specifies the location, certificate store, and subject of a client certificate

To cut a very long (well around 5 hours) story short, this is how I finally got it to work:

[More]

SQL Server 2005 Maintenance Plans not sending email alerts?

SQL Server 2005 does make it much easier to set up email alerts than it's predecessors, however its still very easy to set it up in such a way that emails generated by SQL Agent are not sent, despite test emails being sent without any difficulty.

If your SQL Agent jobs are not sending out emails, and you have set up mail accounts and profiles, together with specifying at least one operator with an email address, and you are getting the following errors in your error logs:

[260] Unable to start mail session (reason: No mail profile defined)

[264] An attempt was made to send an email when no email session has been established

You need to do the following:

  • Right click on SQL Server Agent within Management Studio
  • Select Properties
  • Select Alert System
  • Tick the Enable mail profile checkbox
  • Select Database Mail from the Mail System: select box
  • Select the Mail Profile you wish to use for SQL Agent emails

I believe you then need to restart SQL Server Agent - and providing your profile is set up correctly (and firewall rules permitting) SQL Agent jobs should now send out emails correctly :)

After doing this, it's probably worth checking that emails are working correctly - to do this I set up a simple SQL Agent job containing a single step with a simple select statement, and configured the job to send me an email on completion.  I then ran the task manually, and checked to see the email was received successfully.

SQL Server Maintenance Plan – Rebuild Index Task Gotcha on SQL Server 2005 Standard

Here's one to watch out for if you are setting up a SQL Server 2005 Maintenance Plan on SQL Server 2005 Standard edition

SQL Server 2005 supports online rebuilding of indexes on Enterprise Edition Only

The Task wizard for setting up the Rebuild Index Task has an option Keep index online while reindexing even when connected to Standard Edition.

No warnings are given when setting up a task with this option enabled, but when the maintenance plan executes, the error Online index operations can only be performed in Enterprise edition of SQL Server will be generated for each index - and indexes will not be recreated.

As a side note, make sure you do have the Generate a text file report option ticked within Reporting and Logging  settings for the job, as the information given within the SQL job History Log is limited to The job failed

As a side side note, its definitely worth checking that your SQL Agent email alerts are functioning correctly if you have them set to notify on failure, as otherwise an issue like this can go completely un-noticed (apart from performance issues), as the rest of the tasks within the plan will probably succeed (like backups being generated) - which is certainly the main thing I have always checked after setting up a maintenance plan...

NTLDR is Missing - Issue affecting Dell Laptops

If you have a Dell laptop, and out of the blue you get the error NTLDR is Missing when you turn the machine is turned on, followed by an Invalid MBR error on subsequent reboots - DO NOT PANIC

Chances are, you accidentally pressed the Media Direct Button (looks like a house on my laptop) instead of the Power Button. Now if you have a Dell standard install, this will probably load the Media Direct application - but if you have done a wipe / rebuild, and not set up the Media Direct partion as expected, then you will likely get NTLDR / MBR errors, and an unbootable machine.

When you press this little button, the system rewrites the MBR on the primary disk, and causes the system to boot to a different partition (one which theoretically should contain the Media Direct application). If that partition does not exist, you get an apparently bricked laptop.

The good news is, that if you press the button again, then the changes to the MBR get reverted - may need a subsequent reboot - and you should be able to get back into windows :)

Dangerous button :-/

Using TortoiseSVN to Export Only New/Modified Files

I'm wanting to do this all the time - took me ages to find This article on the VerySimple, Inc. website - reposting so I can find it again!

I'm looking for a simple way of achieving the same with ANT - but not having much luck - if anyone knows how, please post...

ColdFusion Job opportunity in Manchester, UK

A new job opportunity for a ColdFusion developer has just become available in Manchester, UK.

This is at the company that I worked at for 5 years (Gencia Media) - great bunch of people to work with, really friendly.

Click here for job details / contact details.

Updating SVN client version from 1.4 to 1.5 with Eclipse and Subversive with Tortoise SVN on Windows

This process is very very frustrating - but due to the way pretty much every SVN client seems to need to update the working files for any SVN managed resources to the latest version it supports, it does seem to be a necessary process - especially when some other svn plugins (such as Ahnk SVN for visual studio) only support 1.5 or later.

During this process I came across a lot of things that didn't work - I'm just trying to document here what did...

[More]

SQL Server DB documentation from schema

I am in the (fun!) process of documenting an application I created nearly 5 years ago, in which the majority of the functionality is controlled by the database (it's a business workflow automation tool).

Reverse engineering substantially reduces the size of the task - Visio's Database > Reverse Engineer... command is a real time saver when you have foreign key constraints defined, makes generation of an ERD no more complicated than arranging all the boxes so that none (or few!) of the relationship lines cross!

A little utility contributed to the Code Project website makes the process of creating table and field documentation much easier: http://www.codeproject.com/KB/database/sqldoc.aspx

This utility can be pointed at a SQL server database, and will generate an HTML document listing all the tables and fields in the database, together with data types, nullable, default values and description fields from the db schema.

It uses an XSLT transformation to convert the xml generated to an HTML document. This can be edited so that it's closer to final requirements - I have updated the XSLT to place anchors on each table name, and links at the top of the file to each table.

This makes it a much less arduous task to document each table and field - I can edit the file in dreamweaver and just add descriptions for each field and table.

Eclipse Character Encoding issue

I've recently been having the problem that every ColdFusion file that I attempted to open in CFEclipse was displaying character corruption of special characters (e.g. apostrophes, hyphens etc.)  - each corrupted character was being displayed as a black diamond with a question mark in it.

When I checked the character encoding for the file, it was showing as Default (determined from content: UTF-8)

This was not correct - the correct encoding of the files should have been ISO-8859-1.

I checked a number of places, and could not detect where the setting was being applied.  I even tried overriding the Default encoding for the ColdFusion Source File content type - which made no difference at all.

Eventually, the problem turned out to have been caused by me adding the *.cfm extension to the XML Content type (so that I could open any CFM file within the XML editor if required) - which has a default encoding of UTF-8.  This was overriding the setting which had been applied to the ColdFusion Source File content type.

After removing the *.cfm extension from the XML Content type, my ColdFusion files could be opened as saved correctly without any character corruption.

Aggregate Bug? with ColdFusion (8.0.1) Query of Queries

I've been having the following issue with CF8 Query of Queries on ColdFusion 8.0.2:

Iniital query resultset:

attraction_latitudeattraction_longitude
51.4808-0.155075
51.564617-0.092513
51.558144-0.316379

[More]

Google Maps: How to zoom...

The esiest way to zoom in and out on a Google Map, is to use the Mouse Wheel (up for zooming in, and down to zoom out).

Sometimes this isn't possible (by default mouse wheel zoom is disabled for API usage, and it's hard to use a mouse wheel when you're on a laptop with no mouse!)

In this case you can double click with the left button to zoom in (I'm sure everybody knew this) - but you can also zoom out by double clicking the right mouse button.

(And if you are using a Mac Book, then tough luck as Apple are still insisting that a right mouse button is superfluous!!!) (...waits for flames from Mac Fan Boys...)

CFAjaxProxy - don't add the .CFC file extension...

I've been getting the following CF error when attempting to use the CFAjaxProxy tag:

The specified CFC path.to.cfcname.cfc cannot be found

The specified CFC definitely existed, and all the mappings had been set up correctly.

I was calling it with the following code:

<cfajaxproxy cfc="path.to.cfcname.cfc" jsclassname="searchCFC">

I was tearing my hair out for about an hour, before I realised think CF not AJAX - the path to be supplied is in exactly the same format as all CFC references - i.e. excluding the .CFC file extension.

I'm sure this is completely obvious to most people (although at least one guy (thanks Andy) mentioned having done the same thing even today) - but its the obvious ones that seem to catch me out!!!

Weird issue trying to start a CF8 instance

Just had the following issue when trying to start a CF8 instance.

Within the windows services control panel, I clicked start for all of the instances (8) - and they all started except 1.

This was following some fairly in depth reconfiguring of the instances - involving changes to multiple configuration files, the registry, and (perhaps most tellingly) mapping each instance to use its own configuration file by un-registering the windows service, and then re-registering the service using the new config file.

During this process, jrunsvc will stop the service if it is currently running.

When I checked within the JRun {instance name}-out.log file within the instance which would not start, I saw the following error:

error JRun Naming Service unable to start on port 2914
java.net.BindException: Port in use by another service or process: 2914

[More]

How to change the default backup location in SQL Server2005

There doesn't appear to be a simple way of changing this setting from within SQL Server Management Studio.

you can however change this setting by modifying this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\BackupDirectory

This is very handy if you are wanting to restore a load of databases from backup (e.g. when migrating databases from another server...)

64 bit CF8 Compatability issue (Completely irrelevant to most people)

There doesn't appear to be a 64bit driver for MS Access data sources.

I know - no-one in there right mind would use access for driving a website - but we still host a couple (literally) of sites which were created at least 6 years ago and have barely been changed since...

Solution: Import said databases into SQL Server...

SMTP Event Gateway???

Does anyone know of an SMTP event gateway for ColdFusion>

What I'm looking for, is a way of implementing helpdesk type functionality, whereby any emails to a certain domain are handled by ColdFusion according to a set of rules (e.g. create new issue - add comment to an exiting issue etc.)

It struck me that it should be relatively straightforward to handle incoming SMTP transmissions using a ColdFusion Event Gateway (seeing as SMTP is a relatively simple text based prtocol...) - and I wondered if anyone had already done it - and if not - why not? (I'm presuming I must have overlooked something that would make it more complicated than I anticipate...)

ColdFusion 8.01 on Windows - should I go 64 bit?

I'm in the process of specifying a new web server, which will be running ColdFusion 8.01 Enterprise (as well as IIS etc.).

The server will be running ~6 active instances of ColdFusion - and will initially be configured with 4GB RAM - with the option of upgrading in the future as required.

We will be using Windows 2003 Enterprise as the operating system.

What will the benefits and downsides be of going for the x64 OS compared with the x32 OS, taking the following into consideration:

  • The system will only be used as web application server
  • The system will initially be set up with 4GB RAM - and will never have more than 8GB.
  • The high number of instances of CF mean that if we did set the JVM Heap size over the ~1200 MB x32 limit, then we'd run a distinct possibility of running out of memory. (The reason for having so many instances of CF is to enable separation of CF Mail queues - 2 of the instances don't get any front end traffic at all, and are just responsible for sending out large batches of email)

Any advice would be appreciated...

A big thankyou to all those involved in Scotch on the Rocks

Got back home from Scotch on the Rocks - just wanted to publicly thank all those involved with Scotch on the Rocks.

In particular I want to thank Andy Allan and his wife Leanne for the huge amount of time and resource they have given to make this conference the best ever European ColdFusion conference, together with Kev, Stephen and others.

I also want to thank all the speakers - All the presentations I attended were interesting - and some were particularly relevant to where I am now as a developer.

The networking was great - it was particularly good to be able to chat with some of the guys who are leaders within the community - I think this can be even more valuable in many occasions than the sessions - as well as the interaction with Adobe staff.

Thanks Everyone.

How to change ColdFusion / JRun logging location

ColdFusion by default stores log files in 2 locations, dependant on the type:

[More]

Why does anyone use Yahoo email???

A word of advice for anyone using Yahoo mail:

Use Googlemail

Last night, I had to test the formatting of an email generated by our Email Marketing tool within Yahoo mail.

  • The first email I sent arrived immediately
  • The second email I sent did not arrive within an hour and a half
  • The third email I sent (20 minutes later) also did not arrive within that time frame
  • The fourth email I sent (over an hour later) arrived imediately

When I checked yahoo mail this morning, there were four unread emails - including one which had been sent at 16:30 the previous day - this mail took at least 8 hours to arrive!

This in itself should be more than enough to stop anyone using yahoo mail (This is definitely not an isolated instance, we have had several reports of this behaviour from our clients).

In addition, the following would also stop me using yahoo:

  • Extremely intrusive advertising, often taking over ~ 50% of the screen space.
  • The annoying this message was sent using yahoo mail - aren't we fantastic! message which yahoo seem to put into every outgoing email by default
  • When you set up a new account, Yahoo seem to "opt you in" to receive messages within various categories - without warning you that they are going to

Now I appreciate that some people don't get on with the googlemail interface - but if my 60+ year old mum can can cope with moving from yahoo to google (and actually prefers the googlemail interface) - then it can't be that hard!

Add on the fact that you can host email for your own domains there for free - and you get a whole lot of other functionality for free as well (Blackberry / mobile device / POP3 / IMAP access, integration with other Google services etc.) - and the advertising is non intrusive (and often relevant) - then I really can't understand why anyone would use a service which is as dysfunctional and annoying as yahoo's...

Rant over... for now...

What is wrong with Internet Explorer?

I'm currently in the process of setting up a new development machine with all the software I need (Oh what fun!)

I was working may way through my list of essentials (about 90 items and counting!) - installing from disk for stuff on disk, and downloading the most recent versions of apps available on line.

Shortly after installing MS-Office (and running MS Update and rebooting), I tried to download iTunes... I.E. crashed as soon as I had clicked the save to disk button.  I tried again... I.E. crashed again.  So I thought - lets download FireFox and use that instead... I.E. crashed again.

[More]

VMWare Convertor coolness...

Dell have finally deigned to deliver my replacement laptop (Original went in for repair in early December!).

As mentioned previously, I'm in the habit of backing up my machine to an external disk on a regular basis (o.k. maybe not that regular - but at least before it gets taken away for repair!!!) using Acronis True Image.

This offers a handy utility whereby you can mount a disk image as a drive - so I can have full access to the contents of the old hard disk when I need it, from the new machine.

Now I don't know about you, but I find it takes me weeks to get a new development machine up just how I like - and there always seems to be stuff I have forgotten off my old machine...

[More]

More Entries

BlogCFC was created by Raymond Camden. This blog is hosted by DotLance Ltd.