Skip to content

Instantly share code, notes, and snippets.

learncfinaweek

Block or report user

Report or block learncfinaweek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@learncfinaweek
learncfinaweek / gist:4121000
Created Nov 20, 2012
Setup - Installing Sample Files
View gist:4121000

As well as having the ability to read about ColdFusion, 'Learn CF in a Week' has a Hands On section of the course, giving you the opportunity to create your own ColdFusion web site. During the course, you will take a basic HTML website and add ColdFusion to it, creating a fully functional ColdFusion application.

To be able to take part in the Hands On, you must first install the necessary Application files. To do this, follow the steps below:

Windows

View gist:4121270

One could write a book specifically about Object Oriented Programming (OOP). This chapter is an OOP primer to get you started, but for a more in-depth explanation, check out Matt Gifford's Object Oriented Programming in ColdFusion.

What is OOP?

Object Oriented Programming is a set of concepts and techniques that make use of the "object" language construct, to write more reusable, maintainable, and organized code. Objects are implemented differently in every language; in ColdFusion, we have ColdFusion Components (CFCs). Using objects doesn't require OOP, and not every use of objects is OOP. They are simply the building blocks for writing OOP code.

When you write a lot of OOP code, you'll quickly find yourself writing repetitive code to wire together everything necessary to respond to a given request; if you take some time to write a single path through the code that analyzes the request and autom

@learncfinaweek
learncfinaweek / gist:4121405
Created Nov 20, 2012
Error Handling and Debugging - Error Handling
View gist:4121405

While the best efforts are made to stop errors from happening, they do happen. Sometimes the errors might be due to some bad code; other times it may be due to external resources that are out of one's control. During the development process, these errors hold valuable information that allows us to improve and fix our code, but in production environments, these errors hold information that can make our servers vulnerable to attack. It is important that as a developer you anticipate errors and gracefully handle them. Thankfully, ColdFusion offers a number of ways to trap those errors and even allow developers to react to those errors and call alternative functionality.

Understanding Errors

Error Types

View gist:4121263

By now you've learned the basics of ColdFusion, script vs. tag syntax, scopes, how to deal with data, and even some code-reuse techniques. You're now able to write something useful, so it's time we introduce you to the Request Lifecycle.

You see, when someone requests a ColdFusion page, CF doesn't just start executing your code. There are several events that first take place, which you can be waiting for, and to which you can react. This is not strictly necessary, but you'll find that any complex application will eventually want to make use of some or all of these features, so it's best that you know about them. In order to react to these events, you need to have an Application.cfc file. ColdFusion has designated Application.cfc as a special component that it will automatically look for, and in which we can put our event listeners for request lifecycle events.

A Note on Terminolog

@learncfinaweek
learncfinaweek / gist:4120971
Created Nov 20, 2012
Setup - Installing ColdFusion
View gist:4120971

To be able to program in ColdFusion, a ColdFusion server needs to be installed. There are a couple of options available, but the one that we are going to focus on is a local development server.

A local development server is free and allows you to develop ColdFusion applications that use all of ColdFusion’s available features. There are, however, a few limitations, such as not being able to use the server as an external web server. That being said, there are additional benefits to using a local ColdFusion development server, such as not needing to have IIS or Apache installed, but instead using the packaged web server.

To install ColdFusion, follow the steps below:

@learncfinaweek
learncfinaweek / gist:4121009
Created Nov 20, 2012
Basics - Setting Variables
View gist:4121009

Programming is all about doing stuff to things. Generally, the stuff is the execution of a process or algorithm and the things are information or data.

An algorithm is just a fancy name for a series of steps, like tying your shoelaces. Information or data is just values. Your name is a piece of information and so is your birth date. Since it's shorter, in this chapter we'll use the word data to describe a piece of information.

In ColdFusion, data is held in variables. Think of a variable like a mailbox. You can stuff things like letters and packages into a mailbox and get them out later to do stuff. ColdFusion makes storing information very easy because it's a loosely typed Language. You can stick any kind of data into a ColdFusion variable without having to tell ColdFusion what kind of data it is.

View gist:4121356

As you write more and larger ColdFusion applications, you will start looking for ways to improve the performance of your applications. There are many ways to do this, but perhaps the easiest is to use ColdFusion's caching mechanisms to reduce the amount of work your application has to do over and over. Caching simply refers to the idea that you create a piece of content or data once and hold it in application memory for some period of time. During that time frame, any part of your application that needs that content or data uses the copy that was previously generated rather than regenerating it.

ColdFusion has several different caching mechanisms built in, but they generally fall into two main categories--programmatic caching and application server caching.

Programmatic Caching

@learncfinaweek
learncfinaweek / gist:4121390
Created Nov 20, 2012
Security - Secure Password Storage
View gist:4121390

The ARTISTS table in the cfartgallery datasource used for examples is an excellent example of how NOT to store passwords. First, they are stored in clear text and the column is limited to only 8 characters.

ARTISTID
@learncfinaweek
learncfinaweek / gist:4121370
Created Nov 20, 2012
Security - Cross-Site Scripting (XSS)
View gist:4121370

Cross-site Scripting (XSS) is the most prevalent web application security flaw and occurs when user supplied data is sent to the browser without properly validating or escaping that content. XSS flaws can allow the attacker to:

View gist:4121127

Dealing with XML in ColdFusion is fairly straightforward. ColdFusion provides many built-in functions for doing all sorts of XML based operations. Some of those functions provide streamlined access to create, read, and search an xml document. You can also validate XML data against a DTD or schema and transform XML using XSLT.

Reading an XML Document

You can’t perform that action at this time.