Helpful Code Snippets (and app ideas!)

This post is about sharing my ‘Programming Notes and Code Snippets’ document, which I’ve been building on-and-off for a while in the hopes that it might help some of you solve a programming question you have or save you time while you’re building your code project.

I’ve also found this document to be very handy for coming up with new app ideas to get me started using new languages or tool chains. It’s how I got started on Quoats.

Google Wave used to offer this really awesome document embedding feature that doesn’t appear to be available with Google Docs (am I wrong? Correct me, please!), so I’ll just include a link to my code snippets document and an iframe version below.

Note that on all of the code snippets I include a link back to the source that I’m referencing. If these are in error or you’re the owner of the content and want it removed, be sure to drop me a line and I’ll correct the problem. As it is, these code snippets were found scattered across the Internet and this work-in-progress document merely hopes to compile them into something useful.

Enjoy and happy coding.

Movin’ On Up!

DZone MVB

Aw yeah, DZone MVB baby!

Great news! I just received the confirmation E-Mail letting me know I am now an official DZone MVB, or Most Valued Blogger. Blog posts from my Develop in the Google Cloud blog will be featured on the DZone site along with many of the other DZone articles from other MVBs. This will provide some extra exposure to yours truly and makes me really happy to boot!

I’ve been working on a Java/Google App Engine project called Quoats that displays a random quote from around the web. It’s a simple app that I thought would be a great way to get my feet wet with the platform and something I could share on my blog. So far, I am really enjoying a number of things about Google App Engine and Java including JDO and Google App Engine’s persistent storage mechanism. Tres cool.

If you’d like to learn more about Quoats, you can check out the project page (and the source code) on Assembla.

HTML Input Forms – Sending in a List to ColdFusion

HTML + ColdFusion Lists

This post is a continuation of a previous article I wrote about sending in an array through HTML to your php script. This article deals with doing a similar thing except using ColdFusion. If you are new to the subject, it is highly recommended that you read the first article.

Though newer versions of ColdFusion offer support for arrays, earlier versions were centered instead around using lists. Because of this fact, this example will detail how to send a list into ColdFusion then loop over that list, allowing you you to perform whatever actions you need to do in your HTML form.

The Code

<form method="post" action="">
  <p>Enter your friend's names (first, last):</p>
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input maxlength="30" name="friend" size="30" type="text" />
  <input type="submit" value="Submit" />

</form>
<cfif isDefined("Form.friend")>
  <cfloop index="ListElement" list=#Form.friend#>
     <cfoutput>#ListElement#</cfoutput>
     <!--- Do something with this value --->
     </cfloop>
  </cfif>

How It Works

Because all of the <input> elements in the form have the same “name” value, your ColdFusion server will create a list variable called #Form.name# that you will be able to loop through and perform actions on each of the elements.

A handy feature of ColdFusion is that when it creates the list it doesn’t matter if your user enters data only in one of the boxes or only the last one. The list is put together for you of valid inputs from the user. Using this method, you don’t need to check to make sure the value isn’t blank!

Have fun!

Welcome to my blog!

John Rockefeller

John Rockefeller at Synn Studios Inc.

Hi everyone,

First, let me welcome you all to my blog where I will be writing about web development experiences, technology, and social media as I continue along this path in my career. I work as a web developer in the beautiful city of Guelph, Ontario, Canada as a full-time employee but on the side I am part owner of an indie movie studio known as Synn Studios Inc. as well as a maintainer and developer of my own personal technological projects (software or hardware).

Hopefully, if we have similar interests, you will find the posts on this blog to be of use to you either in your own experience or in upcoming projects. If you’re into developing websites, working on servers, making movies, 3D modeling, level design, or game development, there will be something here for you.

I have started two projects on my own: The now defunct NetBoardz Free Forum Hosting, and Jack of All Links – A social search engine (which eats up a lot of my time ;)).

I am available through Facebook, Twitter, MySpace, or LinkedIn, if you need to contact me.

Enjoy!

Reblog this post [with Zemanta]