Tech Demo: Javascript based image magnifier

A javascript based image magnifier. This is great for products or schematics. The user moves a light box over the small image. Next to that, a blow-up image is zoomed and scrolled accordingly. Aside from Scriptaculous, this demo uses only 60 lines of javascript!
View the javascript based image magnifier demo

MySQL and ColdFusion Pagination - version 2

After writing Pagination with ColdFusion and MySQL I tightened up the script some. And with Hatem's suggestions, made it better. So, here is the new version. It's a different application, so the query is slightly different.
My changes in Green, Hatem's in Blue.

<!--- CURRENT PAGE --->
<cfparam name="url.page" default="1">
<!--- RECORDS PER PAGE (ON ALL PAGES) --->
<cfparam name="variables.allperpage" default="15">
<!--- RECORDS PER PAGE (ON FIRST PAGE) --->
<cfparam name="variables.firstperpage" default="#variables.allperpage#">
<!--- NUMBER OF PAGE LINKS AT A TIME --->
<cfparam name="variables.blocksof" default="10">
<cfparam name="url.where" default="ImportDownloaded IS NULL">

<cftransaction>
<cfquery name="orders" datasource="#session.datasource#">
SELECT SQL_CALC_FOUND_ROWS orders.*, orderitems.itemname
FROM orders LEFT JOIN orderItems ON orders.id = orderItems.orderid
WHERE #preserveSingleQuotes(url.where)#
ORDER by orders.datetime DESC, orderitems.itemname
LIMIT
    #firstperpage+(allperpage*(page-1))-allperpage#,
    #iif(url.page is 1,DE(firstperpage),DE(allperpage))#
</cfquery>
<cfquery name="result_count" datasource="#session.datasource#">
SELECT FOUND_ROWS() as howmany
</cfquery>
</cftransaction>

<!--- 'TOP' IS THE LAST PAGE NUMBER LINK --->
<cfset top = blocksof * ceiling((url.page)/blocksof)>

<cfoutput>

<!--- IF WE'RE PAST THE FIRST BLOCK OF PAGES, SHOW THE PREV LINK --->
<cfif url.page gt blocksof>
    <a href="?page=#top-blocksof#&where=#url.where#">« Prev</a>
</cfif>

<!--- LOOP THROUGH THE PAGES IN THIS BLOCK --->
<cfloop from="#top-blocksof+1#" to="#top#" index="a">
<cfif url.page is not a>
    <a href="?page=#a#&where=#url.where#">#a#</a>
<cfelse>
    <b>[#a#]</b>
</cfif>
<!--- IF WE'RE ON THE LAST BLOCK AND DON'T HAVE ENOUGH RECORDS TO COMPLETE THE BLOCK,
    STOP CREATING THE LINKS FOR MORE PAGES, AND SET A FLAG TO NOT SHOW THE LINK FOR THE NEXT BLOCK --->
<cfif ((a-1) * allperpage) + firstperpage gte result_count.howmany>
    <cfset noNext=1><cfbreak>
</cfif>
</cfloop>

<!--- IF WE RAN OUT OF RECORDS, DO NOT SHOW THE LINK FOR THE NEXT BLOCK OF PAGES --->
<cfif not isdefined("noNext")>
    <a href="?page=#top+1#&where=#url.where#">Next »</a>
</cfif>

</cfoutput>

Some pretty good stuff I'd say :)

Thanks Hatem.

Serving gzip compressed Scriptaculous and Prototype with ColdFusion

gzip compressed javascript libraries I love Scriptaculous, and mixing it with ColdFusion to create some very nice Rich Internet Applications. But at nearly 300KB, loading Prototype+Scriptaculous is kinda heavy. The workaround for that is shrinking the javascript libraries.

There are a few utilities around the net that will 'compact' or 'shrink' javascript. Variables are renamed, and all white space is removed - including comments and credits. Not too cool.

But here I'll show you how to take it a step further and serve javascript compressed with coldFusion. I am able to get Prototype v1601 and Scriptaculous v181 download size down from 288KB to 42KB - with credits intact. ColdFusion 8 is not required - I believe CF5 or better will do (maybe even earlier!). This is a great way to serve gzip compressed content when not being able to control the web server and you don't have CF8.

» Continue Reading »

I wish I lived in a bunker

Then I can work in a world without Windows™.

New Wallpaper for the iPhone and iPod Touch

I've added a new download to my repo, http://www.webveteran.com/repo/

It is a wallpaper, poking fun at jailbreaking:


The graphics and text leave ample room for Springboard icons, the Dock, pages, and the unlock screen interface.

To get the full size, you need to load my repository into intaller.app, then look in the Wallpaper section for "Get Out Of Jail Free".

Passwords

We have too many passwords all over the place. They are needed of course. But I think it is harder and more time consuming for me to remember or lookup or try password combinations, than it would be for a hacker to break in for me.

Random SQL Server results - a one word command

I learned a great way to randomize SQL results.

In the past, I would have followed this routine:

Run a query pulling all of the results (tens? hundreds? thousands?).
Create an array.
Loop until 5 good random results are made:
    Get 1 random query result.
    If it's not in the array, put it in.
    If it is in the array, ignore it and try again.
Then I'd output the data from the array, rather than the query.

I suppose I could simply fill an array then randomize it. But that's not really the point.

As you see, with this version we have to pull back so many more results than we're actually going to use. That's wasteful - especially if you want to pull back lots of data in each row.

So what's this great super duper new way I've discovered to simplify code, only pull back the 5 results from SQL Server, and run fast? It's really simple: tell SQL Server to do the work for you, with one word. No post parsing needed!

» Continue Reading »

WebVeteran.com based code deployed on NASA's website

Wow how cool is this?

Scriptaculous' modified version of my JS Audio Engine is being used by NASA!
EX: http://www.nasa.gov

» Continue Reading »

Making a smaller virtual XP machine disk

The problem

As you use your virtual machine, it will continue to grow in size. I have my virtual XP machine to maximum of 10GB. All I really need it for is testing sites in IE6 (ick) and connecting to a SQL Server (ew). After installing a few things, running all Windows Updates... my vanilla XP is using 8GB. Wha? All I have installed is WinAmp, Cisco VNC Client, and SQL Manager. Whats going on?

"Well, when Windows deletes a file, it doesn’t actually delete the data in the disk; it just deletes the references/pointers in the file allocation table. So when ESX is exporting a VMDK and is looking at the raw disk, it’s seeing values that aren’t empty (non-zero), and exports them as such. The result is more disk space is used and takes longer to export the disk."
http://www.rtfm-ed.co.uk/?p=40


The solution

What we want to do is remove all unneccesary files. Caches, installer temps, restore points, and useless software. Then use VMware's Shrink utility to reclaim the disk space. Other virtualization vendors will have similar solutions which may vary. But the build up to the final 'shrink' is the same. All steps are carried out in the guest Windows XP virtual machine.


Results and Benefits

  • Smaller guest OS footprint (mine went from 8GB to 3GB)
  • Smaller virtual disk on the host
  • When zipped, the virtual disc is smaller again (mine is 1.4GB) - making it much more portable
  • With a cleaner guest OS, it runs much faster
  • Suspend/Resume is close to instant

» Continue Reading »

iPhone and iPod Touch Repository

I must have been good. My wife surprised me with an iPod Touch for my birthday. Time to start hacking Laughing

I've created my own repository for software. Enter this address as a source:
http://www.webveteran.com/repo/
There is nothing to see there in a web browser.
But I did make a temporary (or not) browser page for the repo: http://www.webveteran.com/repo/index.html


The first item in my repository is a replacement battery image.

It uses the same UI as iTunes' device capacity indicator:

  
But slickened up for the iPod Touch:
The best guess as to the iPod Touch's battery capacity is 1134 mAh. So instead of using a percent, I did the math, and show the mAh charge.

More gui do-dads to come - stay tuned!

It's not every day one of my clients makes the news

"MRSA infections troubling, but not surprising"

Stories By DAWN ZERA Times Leader Correspondent

An antibiotic-resistant infection nicknamed MRSA, an acronym for methicillin-resistant staphylococcus aureus infection, has made headlines recently. But local medical professionals have known for years that there has been an increase in patients with MRSA.

Kevin Buck, principal of California-based Emergent Success , conducted training sessions on MRSA last week at the Department of Veterans Affairs Medical Center in Plains Township.

Continue reading at timesleader.com

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.6.001.