Do You Have A Permit For Those Guns?

Posted December 14, 2007 at 8:18 AM by Ben Nadel

Tags: ColdFusion, Health / Fitness, Project HUGE

Sorry I was late getting to the gym, but I had to stop off and pick up my permit.

Permit for what?

For these guns!!!:


 
 
 

 
Welcome To The Gun Show - Hot Muscle Chick With Big Bicep  
 
 
 

Anyone who has spent any time in the gym has probably heard a hundred different references to the "Guns". Guns, are of course, your arms. Sometimes referred to as pipes or pythons, the "guns" terminology hit the mainstream when Ubran Outfitters came out with their "Gun Show" t-shirt (as in, Hey ladies, did you have a chance to pick up your tickets for the GUN SHOW!!!!).

Yesterday, I was thinking that it'd be kind of fun to actually make a "Gun Permit" for gym shenanigans. And, it felt like a cool ColdFusion 8 exercise. Here's what I came up with:


 
 
 

 
Gun Permit - Welcome To The Gun Show  
 
 
 

Of course, my arms aren't really that large (at least not yet). The two blank boxes are for the inspector's signature and your signature.

Make your own gun permit here - Online Demo

The ColdFusion 8 code that creates this image is fairly basic. The majority of the graphic is composed of a background image; this contains the field lines and header text. ColdFusion 8 is just being used to input the dynamic form fields based on the user input:

  • <!--- This is the function that adds text to the permit. --->
  • <cffunction
  • name="AddPermitText"
  • access="public"
  • returnvariable="any"
  • output="true"
  • hint="Adds text to the image given gun permit.">
  •  
  • <!--- Define arguments. --->
  • <cfargument
  • name="Permit"
  • type="any"
  • required="true"
  • hint="The permit image object."
  • />
  •  
  • <cfargument
  • name="Text"
  • type="string"
  • required="true"
  • hint="The text to be applied."
  • />
  •  
  • <cfargument
  • name="X"
  • type="numeric"
  • required="true"
  • hint="The X coordinate of the text."
  • />
  •  
  • <cfargument
  • name="Y"
  • type="numeric"
  • required="true"
  • hint="The Y coordinate of the text."
  • />
  •  
  • <!--- Define the local scope. --->
  • <cfset var LOCAL = {} />
  •  
  •  
  • <!--- Turn anti-aliasing on for nice text rendering. --->
  • <cfset ImageSetAntialiasing( ARGUMENTS.Permit, "on" ) />
  •  
  • <!--- Set the drawing color. --->
  • <cfset ImageSetDrawingColor(
  • ARGUMENTS.Permit,
  • "##454545"
  • ) />
  •  
  • <!--- Create the font attributes collection. --->
  • <cfset LOCAL.FontAttributes = {
  • Font = "Courier New",
  • Size = "20"
  • } />
  •  
  • <!--- Draw the text. --->
  • <cfset ImageDrawText(
  • ARGUMENTS.Permit,
  • ARGUMENTS.Text,
  • ARGUMENTS.X,
  • ARGUMENTS.Y,
  • LOCAL.FontAttributes
  • ) />
  •  
  •  
  • <!--- Return the updated image. --->
  • <cfreturn ARGUMENTS.Permit />
  • </cffunction>
  •  
  •  
  •  
  •  
  • <!--- Param form variables. --->
  • <cfparam name="FORM.name" type="string" default="" />
  • <cfparam name="FORM.birthday" type="string" default="" />
  • <cfparam name="FORM.forearm" type="string" default="" />
  • <cfparam name="FORM.arm" type="string" default="" />
  • <cfparam name="FORM.weight" type="string" default="" />
  • <cfparam name="FORM.height" type="string" default="" />
  •  
  •  
  • <!--- Create an array to hold form errors. --->
  • <cfset arrErrors = ArrayNew( 1 ) />
  •  
  • <!---
  • Read in the background image to act as our permit canvas.
  • This includes the design and all the non-dynamic text.
  • --->
  • <cfimage
  • action="read"
  • source="./gun_permit.gif"
  • name="objPermit"
  • />
  •  
  •  
  •  
  • <!---
  • Check to see if the form has been submitted. We will
  • know this if there are any fields listed.
  • --->
  • <cfif StructKeyExists( FORM, "FieldNames" )>
  •  
  • <!--- Validate form data. --->
  • <cfif NOT Len( FORM.name )>
  •  
  • <cfset ArrayAppend(
  • arrErrors,
  • "Please enter your name."
  • ) />
  •  
  • </cfif>
  •  
  • <cfif NOT IsNumericDate( FORM.birthday )>
  •  
  • <cfset ArrayAppend(
  • arrErrors,
  • "Please enter your birthday (mm/dd/yyyy)."
  • ) />
  •  
  • </cfif>
  •  
  • <cfif NOT Val( FORM.forearm )>
  •  
  • <cfset ArrayAppend(
  • arrErrors,
  • "Please enter your forearm circumference in inches."
  • ) />
  •  
  • </cfif>
  •  
  • <cfif NOT Val( FORM.arm )>
  •  
  • <cfset ArrayAppend(
  • arrErrors,
  • "Please enter your upper arm circumference in inches."
  • ) />
  •  
  • </cfif>
  •  
  • <cfif NOT Len( FORM.weight )>
  •  
  • <cfset ArrayAppend(
  • arrErrors,
  • "Please enter your weight."
  • ) />
  •  
  • </cfif>
  •  
  • <cfif NOT Len( FORM.height )>
  •  
  • <cfset ArrayAppend(
  • arrErrors,
  • "Please enter your height."
  • ) />
  •  
  • </cfif>
  •  
  •  
  • <!--- Check to see if any validation errors were found. --->
  • <cfif NOT ArrayLen( arrErrors )>
  •  
  • <!--- Date issued. --->
  • <cfset AddPermitText(
  • objPermit,
  • DateFormat( Now(), "mm-dd-yyyy" ),
  • 375,
  • 53
  • ) />
  •  
  • <!--- Printed name.. --->
  • <cfset AddPermitText(
  • objPermit,
  • FORM.name,
  • 26,
  • 103
  • ) />
  •  
  • <!--- Date of birth. --->
  • <cfset AddPermitText(
  • objPermit,
  • DateFormat( FORM.birthday, "mm-dd-yyyy" ),
  • 375,
  • 103
  • ) />
  •  
  • <!--- Forearm size. --->
  • <cfset AddPermitText(
  • objPermit,
  • "#NumberFormat( Val( FORM.forearm ), '0.0' )#""",
  • 26,
  • 153
  • ) />
  •  
  • <!--- Upper arm size. --->
  • <cfset AddPermitText(
  • objPermit,
  • "#NumberFormat( Val( FORM.arm ), '0.0' )#""",
  • 155,
  • 153
  • ) />
  •  
  • <!--- Weight. --->
  • <cfset AddPermitText(
  • objPermit,
  • FORM.weight,
  • 284,
  • 153
  • ) />
  •  
  • <!--- Height. --->
  • <cfset AddPermitText(
  • objPermit,
  • FORM.height,
  • 413,
  • 153
  • ) />
  •  
  • <!--- Name and title of officer. --->
  • <cfset AddPermitText(
  • objPermit,
  • "Inspector in",
  • 330,
  • 180
  • ) />
  •  
  • <!--- Name and title of officer. --->
  • <cfset AddPermitText(
  • objPermit,
  • "Charge",
  • 330,
  • 203
  • ) />
  •  
  • <!--- Name and address of location. --->
  • <cfset AddPermitText(
  • objPermit,
  • "Project Huge Fitness New York, NY 10011",
  • 26,
  • 253
  • ) />
  •  
  • <!--- Badge no. --->
  • <cfset AddPermitText(
  • objPermit,
  • RandRange( 1000, 9999 ),
  • 413,
  • 291
  • ) />
  •  
  • <!--- Permit no. --->
  • <cfset AddPermitText(
  • objPermit,
  • RandRange( 1000, 9999 ),
  • 413,
  • 322
  • ) />
  •  
  • </cfif>
  •  
  • </cfif>
  •  
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  • <html>
  • <head>
  • <title>Gun Permit Using ColdFusion 8</title>
  •  
  • <style type="text/css">
  •  
  • body {
  • font-family: verdana, arial, sans-serif ;
  • font-size: 62.5% ;
  • }
  •  
  • div.errors {
  • color: #CC0000 ;
  • }
  •  
  • div.errors h4 {
  • font-size: 1.4em ;
  • font-weight: bold ;
  • margin-bottom: 7px ;
  • }
  •  
  • div.errors ul {
  • font-size: 1.2em ;
  • line-height: 1.4em ;
  • margin-top: 0px ;
  • }
  •  
  • form {
  • position: relative ;
  • }
  •  
  • label {
  • display: block ;
  • font-size: 1.4em ;
  • margin-bottom: 5px ;
  • }
  •  
  • input {
  • display: block ;
  • margin-left: .5in ;
  • width: 175px ;
  • }
  •  
  • div#permit {
  • border: 1px solid #333333 ;
  • left: 325px ;
  • position: absolute ;
  • width: 545px ;
  • top: 5px ;
  • z-index: 100 ;
  • }
  •  
  • </style>
  • </head>
  • <body>
  •  
  • <cfoutput>
  •  
  • <h1>
  • Gun Permit Using ColdFusion 8
  • </h1>
  •  
  •  
  • <!--- Check to see if there are any errors. --->
  • <cfif ArrayLen( arrErrors )>
  •  
  • <div class="errors">
  •  
  • <h4>
  • Please review the following:
  • </h4>
  •  
  • <ul>
  • <cfloop
  • index="strError"
  • array="#arrErrors#">
  •  
  • <li>
  • #strError#
  • </li>
  •  
  • </cfloop>
  • </ul>
  •  
  • </div>
  •  
  • </cfif>
  •  
  •  
  • <form action="#CGI.script_name#" method="post">
  •  
  • <label for="name">
  • Name (First, Middle initial, Last):
  • </label>
  •  
  • <input
  • type="text"
  • name="name"
  • id="name"
  • value="#HtmlEditFormat( FORM.name )#"
  • />
  •  
  • <br />
  •  
  • <label for="name">
  • Birthday (mm/dd/yyyy):
  • </label>
  •  
  • <input
  • type="text"
  • name="birthday"
  • id="birthday"
  • value="#HtmlEditFormat( FORM.birthday )#"
  • />
  •  
  • <br />
  •  
  • <label for="forearm">
  • Forearm Circumference:
  • </label>
  •  
  • <input
  • type="text"
  • name="forearm"
  • id="forearm"
  • value="#HtmlEditFormat( FORM.forearm )#"
  • />
  •  
  • <br />
  •  
  • <label for="forearm">
  • Upper Arm Circumference:
  • </label>
  •  
  • <input
  • type="text"
  • name="arm"
  • id="arm"
  • value="#HtmlEditFormat( FORM.arm )#"
  • />
  •  
  • <br />
  •  
  • <label for="weight">
  • Weight:
  • </label>
  •  
  • <input
  • type="text"
  • name="weight"
  • id="weight"
  • value="#HtmlEditFormat( FORM.weight )#"
  • />
  •  
  • <br />
  •  
  • <label for="weight">
  • Height (F'I&quot;):
  • </label>
  •  
  • <input
  • type="text"
  • name="height"
  • id="height"
  • value="#HtmlEditFormat( FORM.height )#"
  • />
  •  
  • <br />
  •  
  • <input
  • type="submit"
  • value="Build Gun Permit &raquo;"
  • />
  •  
  •  
  • <!--- Write to the browser. --->
  • <div id="permit">
  •  
  • <cfimage
  • action="writetobrowser"
  • source="#objPermit#"
  • format="gif"
  • />
  •  
  • </div>
  •  
  • </form>
  •  
  • </cfoutput>
  •  
  • </body>
  • </html>

This was just a post for fun, nothing revolutionary going on here.



Reader Comments

Dec 14, 2007 at 9:08 AM // reply »
92 Comments

Ben...

If your card is correct, you and I share a birthyda, albeit I was born in 1971, rather than 1980.

So Happy Birthday to you!


Dec 14, 2007 at 9:14 AM // reply »
11,246 Comments

@Andy,

That birthday is accurate. Very cool. AND, we both share the day with Bill Murray. I don't know about you, but that's pretty awesome in my book :)


Dec 14, 2007 at 9:15 AM // reply »
16 Comments

hehe, that's awesome!

cool use of cfimage..


Dec 14, 2007 at 9:22 AM // reply »
92 Comments

I didn't know that, and yes...that IS really cool. He's got to be one of the funniest guys to come around in the last 30 years.


Dec 14, 2007 at 9:25 AM // reply »
11,246 Comments

@Andy,

Have you seen this video on Fact Checking:

http://www.funnyordie.com/videos/eae26bb96d

Quality stuff and unexpected Murray.


Roe
Dec 14, 2007 at 12:47 PM // reply »
10 Comments

"That's a man, BABY!"
-- Austin Danger Powers


Dec 18, 2007 at 9:14 AM // reply »
33 Comments

Ben, call me paranoid but I'd be careful about putting your DoB up on a public site. Combine that with the address data from your whois record and your employer details and you're in a huge mess if someone gets credit cards in your name.


Dec 18, 2007 at 9:25 AM // reply »
11,246 Comments

@George,

You make a good point. As someone who has never had to deal with any kind of theft of any kind (I never even had a calculator stolen in school), I have a certain amount of boyish naiveté. But, that doesn't mean I shouldn't be cautious. Thanks for the reality check. I will look into making things more secure.


Rob
Feb 21, 2008 at 12:16 PM // reply »
1 Comments

dude.. that's damn entertaining.


Apr 4, 2008 at 11:54 AM // reply »
11 Comments

I honestly can't believe you spent time writing this code. And here I thought you were lazy :S.


Apr 25, 2008 at 3:20 PM // reply »
3 Comments

You are such a dork, haha! But, Bravo! It's hilarious. I should come up with something like that for runners like my friends and myself. :)


Apr 25, 2008 at 4:15 PM // reply »
11,246 Comments

@Aliksandra,

Glad to entertain... and perhaps... inspire??


bob
Mar 11, 2009 at 5:47 PM // reply »
1 Comments

dang wats her name


Mar 11, 2009 at 6:27 PM // reply »
11,246 Comments

@bob,

I wish I knew :)


Feb 6, 2010 at 12:00 PM // reply »
1 Comments

Ben,
I learn a lot from you. I created an
Emergency Zombie Defense Station Sign Maker based on your gun permit code.

http://zombiesign.com/


Feb 6, 2010 at 12:08 PM // reply »
11,246 Comments

@Chris,

Ha ha, that's awesome :)



Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 25, 2013 at 10:08 AM
Using "//" And ".//" Expressions In XPath XML Search Directives In ColdFusion
@Ben, my question is that i want the current node with its tag and its parent node. i just want only that data. So, give me the solution for that. and remember solution is working on " xpath 1.0 ... read »
May 25, 2013 at 10:01 AM
Using "//" And ".//" Expressions In XPath XML Search Directives In ColdFusion
hey ben, i want get my current node tag and also want the root node tag withing. So, how can i fix it.. ! ... read »
May 24, 2013 at 5:39 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
@Adam Oops! My mistake! I hadn't gotten that far in my testing - I'm still baby stepping my way through the process. ... read »
May 24, 2013 at 5:13 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
Hi Jason, Thanks for checking up on that, but I still stand firm on my position. :) There are actually two listLast()'s in use, and you're right that the one using a space as a delimiter is fine. ... read »
May 24, 2013 at 4:45 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
@Ben I have been lurking your site for quite some time, and haven't stepped up to comment until today. Thanks for all the great info - keep it up! @Adam I believe you are mistaken... as the commen ... read »
May 24, 2013 at 11:21 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@WebManWalking, Ha ha, let's us never speak of justifying "##" notation again :P ... read »
May 24, 2013 at 11:18 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben, Ah, so it was indeed how I vaguely remembered it to be: A direct assignment value = users.id[ i ] causes value to retain the sticky datatype of the query column. Although unnecessary in ... read »
May 24, 2013 at 9:11 AM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Brandon, Hi, No, I haven't been able to do that. I have just kept it as it is. ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools