Tuesday, July 5, 2011

cfsavecontent vs CSS when wanting to add styles.

I ran into some confrontation when I decided to use a cfsavecontent and write some styles in <style/> tags and do a <cfhtmlhead/>. Another developer prefers everything in a .css file. While, yes all styles are in one place in the app, unneeded styles are being loaded on pages that don't need them.

I prefer the other route of doing styles in style tags on the page I am working in and then adding them to the head section. Don't get me wrong I still have some global styles set in .css files. Most of the pages I am working on are all custom interfaces and the .css file(s) would be unnecessary large between pages. Not to mention lots and/or large .css files bring down browser load time.

Thoughts?

Submit button name when posting form in JS

I am sure plenty of people out there have had this issue. So I had a submit button named "submit" and tried to do form submit in js by doing $("#theform").submit(); and I kept getting this error saying that .submit() wasn't a function. After some digging apparently if you name a submit button in a form "submit" it overwrites the submit() with submit button element. Not cool.

Thursday, June 23, 2011

Developer Phases

1. How do I do that? (Entry)
2. Yeah, I can do that. (Mid)
3. Sigh. What was I thinking when I wrote this? (Adv)

Wednesday, June 15, 2011

Hover Bike

I am a big fan of hover technology and want to share this break through with a hover bike.

http://gearpatrol.com/blog/2011/06/09/bmw-powered-twin-rotorhoverbike/

It kind of reminds of a speeder bike from Star Wars.

Writing text over an image

I know alot of people have already done this, but I thought I would share writing text over image as well. Only because the first time you do it, it's really cool.

Read in the image

<cfimage name = "local.image" action="read" source="test.jpg"/>


Turn on anti-aliasing ("softens jagged edges")

<cfset ImageSetAntiAliasing(local.image)/>


Set the text color

<cfset ImageSetDrawingColor(local.image, "000000")/>


Set extra attributes

<cfset local.attrs = {
Font = 'Arial',
Size = 36,
Style = 'bold'
}/>


Draw over the image (image,text,x-position,y-position,attributes)

<cfset ImageDrawText(local.image, "Hello World!", 10, 10, local.attrs)/>

SQL replace() blank stuff

Will never return 0

select replace('','',0)


Will return zero if the value is ''

select case when '' = '' then 0 else 1 end

SQL Selects ='s

Instead of writing a select in a query like this


select
[user].id,
[user].name,
snowboard.name as snowboard
from [user]
inner join snowboard on snowboard.id = [user].snowboard_id


try this


select
[user].id,
[user].name,
snowboard = snowboard.name
from [user]
inner join snowboard on snowboard.id = [user].snowboard_id


It helps all the columns line up and read nicer.