Blogs RSS

1 - Moving Pic of the Day Foiled Again

A while back I made an attempt to move Pic of the Day (NSFW) off of ColdFusion 8 and onto Railo 3.  I can't afford a license of CF9, so my only upgrade path is through a free alternative.  Unless someone has an extra four grand they want to give me…. Last time I was foiled [...]
Read more...
Aggregated from: http://feedproxy.google.com/~r


2 - Moving Pic of the Day Foiled Again

A while back I made an attempt to move Pic of the Day (NSFW) off of ColdFusion 8 and onto Railo 3.  I can't afford a license of CF9, so my only upgrade path is through a free alternative.  Unless someone has an extra four grand they want to give me….

Last time I was foiled by CFHTTP adding a spurious Content-Type header on GET requests, which breaks secure downloads from S3 (which is where I host all the content).  I reported the bug and it got fixed, but I hadn't had time to revisit the migration process so there it sat.  Until this evening, that is.

I'm glad to say that the issue with GET requests has been completely resolved.  The bleeding edge is also a lot smoother than last time I pulled down a new version, so props to those guys.  Setting up a migration test environment actually proved pretty straightforward, even with all the crazy Apache and OS integration PotD leverages.

As expected, there were errors on the first page load, but nothing some trickery with mappings and rewriting a couple query of queries couldn't fix.  After that, everything just worked.  Thumbnail generation, S3 access, emailing, everything.  Except that it wasn't everything.  Turns out that exactly the same problem I had with GET requests before has no manifested itself with DELETE requests.  So I'm again stuck.

The way PotD is implemented, images are spidered and pushed immediately onto S3.  Then they go through the filter pipeline, and many (most?) of them are deleted.  So being able to remove stuff from S3 is a pretty core feature, otherwise I'd have piles and piles of orphaned files up there, and that just costs me money for no reason.  Sadly, this makes Railo a no-go again, and leaves me with CF8 for a while longer.

I've actually got a lot of stuff in the works surrounding my personal sites and projects, but the CF to Railo conversion is one of the larger ones as well as the one with the largest potential impact on server resources (which I'm continually constrained by).  The move from JRun to Tomcat was a huge help, but I could definitely use more and Railo gives all apperances of being able to give it to me.  Also have some major WordPress infrastructure changes, a whole rebranding of this (my blog), and a few other corollary improvements.

The overarching goal is to simplify my URL space so I don't have as much interleaving between separate applications.  www.barneyb.com's URL space, for example, houses 3 different blogs, two static sites, and a pile of little CFML apps.  ssl.barneyb.com houses SVN, Trac, PotD, and several other CFML apps.  It's a mess, but that'll be a lot better, regardless of what happens with the CFML engine stuff.


Read more...
Aggregated from: http://feedproxy.google.com/~r


3 - A Special ColdFusion Builder Event in Tampa, FL

Special Cold Fusion Builder Event March 24th at 7 pm Location: GCA Technology Services in Tampa, FL 4919 Memorial Hwy. Suite 150 Tampa, FL 33634 http://www.meetup.com/florida-web-developers/calendar/12754891/?a=cv1p_grp&rv=cv1p
Read more...
Aggregated from: http://ricardo.parente.us/2010


4 - Fake Filenames for Far Future Expires Headers

Everyone knows that one of the best ways to increase page performance is to reduce the number of HTTP requests required for related assets.  There are a pile of ways to approach this (JS/CSS aggregation, image sprites, caching), but the best (and simplest) is client-side caching.  It doesn't help your first-time visitors at all (which is why you still need to look at other optimizations), but for repeat visitors and people who stick around for more than one page caching is a huge win.

The key to all of this is the Expires header: you want to set an expiration way in future so the client (the browser) will cache the asset forever.  With Apache it's really simple:

LoadModule expires_module modules/mod_expires.so
ExpiresByType   application/x-javascript    "now plus 10 year"

That tells Apache to set an expiration on all JS files that is 10 years in the future.  In web time, that's pretty much forever.  Really simple, really effective.  You also want to use mod_headers to set Cache-Control and Pragma headers and remove the ETag and Last-Modified headers, as well as ensure we don't use file ETags:

LoadModule headers_module modules/mod_headers.so
Header  set     Cache-Control    "public"
Header  set     Pragma           ""
Header  unset   Last-Modified
Header  unset   ETag
FileETag        None

The problem is that if you ever change one of those JS files, clients who already have the old version will never know about it.  The solution is to never modify files, only create and delete files.  So if you have 'script.js' and you need to make an update, instead of pushing a new version of that file, you'd instead push 'script_2.js' (or whatever).  That way you're guaranteed that every client will download it afresh (with the long Expires header) because no one has ever seen the file before.  Next time you need to make changes, you'd push 'script_3.js'.

This quickly becomes a bit of a problem, because not only do you have to change the filename, you have to change all the references to the filename as well.  So a little JS tweak suddenly becomes a change to all your SCRIPT tags and republishing all your content.  Not too fun.  This is the problem I can help solve, and it'll be using our friend mod_rewrite (of course!).

Check this innocuous little condition/rule:

RewriteCond    %{REQUEST_FILENAME}    !-s
RewriteRule    (.*)_[0-9]+\.js$    $1.$2

That says any time you find a JS file that ends with an underscore followed by one or more digits, if it doesn't exist, remove the underscore and digits.  I.e. when 'script_2.js' gets requested, if that file doesn't exist, just serve back 'script.js' instead.  Now that's handy, because now we can use an arbitrary version number and they all hit the same file.  This is not a perfect solution, but it is ideal for the vast majority of cases, since you can just modify 'script.js' in place without a care in the world, and then reference your incrementing scripts to ensure cache refreshes.  Because HTTP caching operates on HTTP URIs, the fact that requests for 'script.js' and 'script_2.js' both hit the same file on disk is irrelevant; they're separate URIs, so they'll be cached separately.

That's not a solution in and of itself, however, because we still have to update all the SCRIPT tags to use a new filename (even though it'll end up hitting the same file on disk).  But now that the URI is divorced from the file itself, we don't have to keep anything in sync.

The last piece is to set up a global variable to use in your script suffixes:

<cfset application.scriptVersion = 2 />
...
<script type="text/javascript" src="/path/to/script_#application.scriptVersion#.js"></script>

Then any time you increment that scriptVersion variable, all your JS will suddenly become uncached and everyone will refresh.  So you can just hack away on script.js until you're happy, bump the variable up, and you're done.  No new files, no changing SCRIPT tags, super simple.


Read more...
Aggregated from: http://feedproxy.google.com/~r


5 - ColdFusion Contract Job in Marbella, Spain

MyDestinationInfo In a nutshell, we are an exciting UK based specialist travel company and we are looking to recruit an experienced website developer/programmer whom is proficient ColdFusion (min 2/3 years, the more the better). Our technical office is based in sunny Marbella, Spain. Working as part of a young and highly creative team, we want someone [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


6 - ColdFusion Job Opportunity in West London, United Kingdom

Martech Social Responsibilities Work on new products as well as supporting our existing applications. Responsible for designing new features and functionality, writing API’s, making performance, scalability and maintainability improvements. Play an active role in the architecture of our core M.Social platform using ColdFusion, HTML, CSS, JavaScript and SQL Server 2005/2008. Administer and maintain web and database servers. Other Software engineering/developer duties [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


7 - ColdFusion Job Opportunity in Bethesda, MD

SRA- Health and Civil Services has an opportunity for a Web Developer (Cold Fusion) in Bethesda, Maryland. This position will be responsible for testing of each solution in appropriate QA environment, adhering to departmental standards, policies and procedures, to ensure proper performance and efficiency. The Web Developer (Cold Fusion) will document programs in accordance with development standards [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


8 - ColdFusion Job Opportunity in Springfield, MO

yTen Business Solutions is a progressive Internet-based business development company located in Springfield, Missouri. Responsibilities: You would be responsible for Internet programming for our various Web sites. Experience with Internet programming languages(ColdFusion a plus) and SQL is required. Interest in travel is a plus as you will be primarily working with vacation web sites. Here is the [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


9 - ColdFusion Job Opportunity in Seattle, WA

Mandatory Skill Sets: Coordination and documentation of project specifications, development timelines and task lists Ability to execute the development of business applications within designed project timelines and resource requirements Debugging/​QA and organization skills Ability to learn quickly and practically apply new concepts or principles Ability to communicate with all departments and all organizational levels Minimum Qualifications: Bachelor’s degree [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


10 - ColdFusion Builder - Refactoring

I don't know about you - but every time I hear about refactoring in an IDE, I break out in a case of the cold sweats. It's the same way I feel about multi-file search and replace. Sure it's a great feature, but the idea of updating hundreds of files ... [More]
Read more...
Aggregated from: http://www.coldfusionjedi.com/


11 - ColdFusion Builder - Refactoring

I don't know about you - but every time I hear about refactoring in an IDE, I break out in a case of the cold sweats. It's the same way I feel about multi-file search and replace. Sure it's a great feature, but the idea of updating hundreds of files at one time and not screwing up just freaks me out. That being said, I decided to just get over my fears and take a quick look at refactoring in ColdFusion Builder. To be honest, I would not have played with this feature at all if I hadn't discovered that it has a preview function. So if the thought of accidentally spreading a typo across a thousand files worries you as well - at least know that you can see exactly what changes will be made before committing to actually modifying your files. [More]


Read more...
Aggregated from: http://feedproxy.google.com/~r


12 - ColdFusion Job Opportunity in Raleigh, NC

TEKsystems has partnered with an employer in Raleigh, North Carolina in a search for a Jr. Web Developer. This is a long-term contract with excellent growth potential. We need to bring on an additional JR Level Applications Developer. This person will join a team of 9 other developers. They will do daily application support on 140 [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


13 - ColdFusion Job Opportunity in Quincy, MA

PaperThin Specific Responsibilities Install CommonSpot in multiple server configurations (which include multi-server environments on Windows, Solaris and Linux) Implement CommonSpot on-site (which includes custom code developed “on the fly” to integrate with internal systems and CommonSpot API calls) Train technical individuals on the use of the CommonSpot product Assist the internal PaperThin Support Desk with potential issues which arise from [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


14 - ColdFusion Job Opportunity in Memphis, TN

Responsible for coding, testing and analyzing application software. Supports existing business systems applications. Partners with business analysts to identify business needs and appropriate technical solutions. Responsible for designing and documenting technical requirements for business applications… Candidate Requirements: 3+ Years of ColdFusion and MS SQL experience, including T-SQL and stored procedures. Familiarity with ColdSpring, Flex, .NET, or JSP [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


15 - ColdFusion Job Opportunity in San Antonio, TX

MISI Company Description Responsibilities: Active in the life cycle (analysis, design, code, test, installation and maintenance) of web-based software applications – ensuring these applications interact with existing applications. Works with minimal guidance; seeking guidance only on the most complex tasks. Integrates ColdFusion and Java web technology into all aspects of business operations Integrates Visual Basic and PowerBuilder client/server technology with [...]
Read more...
Aggregated from: http://ricardo.parente.us/2010


16 - Using Base64 Canvas Data In jQuery To Create ColdFusion Images

Last week, I explored the HTML Canvas element for the first time. In that exploration, I created a "finger painting" demo for the iPhone that would post drawing commands to the server where the image would be re-created as a PNG in ColdFusion. That was a nice approach because it gave me some flexibility in how the ColdFusion image was created (using anti-aliasing and a t ... Read More »
Read more...
Aggregated from: http://www.bennadel.com/blog/1


17 - REReplaceCallback UDF

If you've used pretty much any modern language, you know all about callback functions.  Unfortunately CFML is capable of doing it, but the language itself doesn't leverage the feature anywhere.  In particular, a callback for the replace operation is of great value.  Ben Nadel has blogged about such things a couple times, and now I'm doing the same.  First, here's how you use it:

<cfscript>
string = "The catapult bifurcated the bearcat.";
fancyString = REReplaceCallback(string, "(\w*)(cat)(\w*)", doit, "all");
function doit(match) {
  if (match[2] EQ "") {
    return '#match[2]#<b><i>#match[3]#</i></b>#match[4]#';
  } else {
    return '<u>#match[2]#<b><i>#match[3]#</i></b>#match[4]#</u>';
  }
}
</cfscript>

As you'd imagine, the 'doit' function is invoked for each match of the regular expression (in this case looking for a literal "cat" surrounded by any number of word characters).  It then does a check on match[2] (the leading word characters) to see if it's empty and then forks based on that result (either underlining or not).  The 'match' array, as you might surmise, contains the matched expressions.  The first index is the entire expression, and an additional index is added for each subexpression in the regular expression.  In this case, there are three subexpressions, so the 'match' array will have length 3 + 1 = 4.

This particular conditional can be performed without a callback.  Here are a pair of REReplace calls that do it:

<cfscript>
string = "The catapult bifurcated the bearcat.";
fancyString = REReplace(string, "(\W|^)(cat)", "\1<b><i>\2</i></b>", "all");
fancyString = REReplace(fancyString, "(\w+)(cat)\w*", "<u>\1<b><i>\2</i></b>\3</u>", "all");
</cfscript>

The first one takes care of words starting with 'cat', the second words with 'cat' inside or at the end.  Note that this only works because the result of the first replace does NOT put word characters next to 'cat' in the replacement string.  If it did that, we'd be screwed, because the two replaces happen sequentially, not in parallel.

In this particular case, neither one of them is very readable.  :)  With a little cleanup and a well-named temp variable, I'd say the callback version has the potential to be more readable, but the pair of REReplaces is pretty much stuck as-is.  As things get more complicated, however, the callback approach becomes dramatically clearer.

The big win, of course, has nothing to do with conditional replaces.  Rather, it's the ability to execute arbitrary CFML code to generate the replace string based on the matched string.  Your callback can do anything you want: go hit the database, shell out to a web service, go grab a dynamically selected bean from ColdSpring and get a value from it, etc.  The sky's the limit.

Here's the REReplaceCallback UDF itself:

<cffunction name="REReplaceCallback" access="private" output="false" returntype="string">
  <cfargument name="string" type="string" required="true" />
  <cfargument name="pattern" type="string" required="true" />
  <cfargument name="callback" type="any" required="true" />
  <cfargument name="scope" type="string" default="one" />
  <cfscript>
  var start = 0;
  var match = "";
  var parts = "";
  var replace = "";
  var i = "";
  var l = "";
  while (true) {
    match = REFind(pattern, string, start, true);
    if (match.pos[1] EQ 0) {
      break;
    }
    parts = [];
    l = arrayLen(match.pos);
    for (i = 1; i LTE l; i++) {
      if (match.pos[i] EQ 0) {
        arrayAppend(parts, "");
      } else {
        arrayAppend(parts, mid(string, match.pos[i], match.len[i]));
      }
    }
    replace = callback(parts);
    start = start + len(replace);
    string = mid(string, 1, match.pos[1] - 1) & replace & removeChars(string, 1, match.pos[1] + match.len[1] - 1);
    if (scope EQ "one") {
      break;
    }
  }
  return string;
  </cfscript>
</cffunction>

Lots of stuff going on in there, but it's basically just doing a REFind with returnsubexpressions=true, ripping apart the string to pass the pieces to the callback function, and then reassembling the string afterwards.  It'd be trivially easy to make a REReplaceNoCaseCallback function, but I haven't done.  I've implemented the function with CFFUNCTION/CFARGUMENT tags so that I can have an optional fourth parameter on CF8, but the body as CFSCRIPT so that if you want to use the UDF in pure CFSCRIPT on CF9, you only have to rewrap the body (not reimplement).

This particular implementation differs from what you might expect in that the callback gets substrings instead of position/length tuples (i.e., the way REFind works).  I opted for this approach for two reasons: first it removes the need for the callback to have access to the raw string, and secondly all you do with the len/pos is rip the string apart to get the characters so why make every callback do it.

Why did I write this?  Just for fun?  No, not at all.  I needed a way of doing rich inline markup with tags that could be implemented via plugging for a project (you get one guess), and after playing with a couple formats I concluded that porting WordPress's shortcodes was as close to an optimal solution as I was going to get.  The shortcode implementation requires this sort of conditional replace operations, so I built this UDF.  If you do PHP, it's basically equivalent to preg_replace_callback but with CFML argument ordering.

Yes, I'll be sharing the CFC that implements shortcodes (complete with a port of the WordPress unit tests from PHPUnit to MXUnit), but not right this second.

<cffunction name="REReplaceCallback" output="false" returntype="string">
<cfargument name="string" type="string" required="true" />
<cfargument name="pattern" type="string" required="true" />
<cfargument name="callback" type="any" required="true" />
<cfargument name="scope" type="string" default="one" />
<cfset var start = 0 />
<cfset var match = "" />
<cfset var parts = "" />
<cfset var replace = "" />
<cfset var i = "" />
<cfloop condition="true">
<cfset match = REFind(pattern, string, start, true) />
<cfif match.pos[1] EQ 0>
<cfbreak />
</cfif>
<cfset parts = [] />
<cfloop from="1″ to="#arrayLen(match.pos)#" index="i">
<cfif match.pos[i] EQ 0>
<cfset arrayAppend(parts, "") />
<cfelse>
<cfset arrayAppend(parts, mid(string, match.pos[i], match.len[i])) />
</cfif>
</cfloop>
<cfset replace = callback(parts) />
<cfset start = start + len(replace) />
<cfset string = mid(string, 1, match.pos[1] – 1) & replace & removeChars(string, 1, match.pos[1] + match.len[1] – 1) />
</cfloop>
<cfreturn string />
</cffunction>

Read more...
Aggregated from: http://feedproxy.google.com/~r


18 - My move from using cfhttp and rssatom.cfc to cffeed.

For the last year or so, I had been using cfhttp and rssatom.cfc to read and parse rss feeds so that I could display the content on a site running on ColdFusion 7. I recently upgraded the server to ColdFusion 9, but shortly afterward started to receive the error, "An error occurred while Parsing an XML document. Content is not allowed in prolog". The error was not consistent, but occurred twenty to thirty times a day. I figured it was a good time to move to the more current cffeed tag that became available in ColdFusion 8 and see if
Read more...
Aggregated from: http://www.john-sieber.com/pos


19 - Infinite entities, cfgrid and one cfc to handle the data

While writing SpreadEdit I wanted every entity to be editable via cfgrid.  In particular I thought it would be cool to have one cfc on the back end to process the data from cfgrid no matter what entity it was working with.  With ColdFusion 9 and ORM this proved possible and is pretty cool, check out the screencast.  Code the other side of the embed. Here is the code for genericGrid.cfc: <cfcomponent>   <cffunction name="getData" access="remote" returnformat="JSON">      <cfargument name="page" required="true">      <cfargument name="pageSize" required="true">      <cfargument name="gridSortColumn" required="true">      <cfargument name="gridSortDirection" required="true">      <cfargument name="entity" required="true">        <cfif ! len(
Read more...
Aggregated from: http://samfarmer.instantspot.c


20 - Job: ColdFusion Developer - Marbella, Spain

In a nutshell, we are an exciting UK based specialist travel company and we are looking to recruit an experienced website developer/programmer whom is proficient ColdFusion (min 2/3 years, the more the better). Our technical office is based in sunny Marbella, Spain. Working as part of a young and highly creative team, we want someone who also has a bit of an eye for design, and who is very experienced with JavaScript, SQL, XML & HTML/CSS. This will be a full time contracted position offering a net salary (taxes and social security paid on top of this) of circa €1500
Read more...
Aggregated from: http://www.ukcfug.org/post.cfm