Display image when completely loaded with Javascript

Today, I need to test some simple javascript coding to detect image manipulation. As we all know, we cannot detect Image width and height with javascript or jQuery before which isn't completely loaded. Now what I want to do is just put loading text and don't show image while it's not completely loaded. It's quite simple and I feel what I want to do might be useful for my future projects. Because I feel displaying image while loading is annoying and shouldn't be good for our clients. That's why I have an idea to do like that.

view plain print about
1<img id="imageid" src="very_big_image.jpg">
2<span id="loadText"></span>
3
4/* Below part is Javascript Coding */
5document.onreadystatechange=function()
6{
7    /*
8        if page/dom/image is completely loaded,
9        show image and remove loading text.
10    */

11    if (document.readyState == "complete")
12        {
13            document.getElementById("imageid").style.display = "inline";
14            document.getElementById("loadText").innerHTML = "";
15        }
16}
17/* hide image and display loading while loading */
18document.getElementById("imageid").style.display = "none";
19document.getElementById("loadText").innerHTML = "Loading...";

Concurrency between CFLock and CFTransaction

In these days, our project encounter concurrency issues which mean two users can access to one item and this item cannot be correctly updated after processing. As we all, Coldfusion provide CFLock and CFTransaction for concurrency but I don't know which one is useful and suitable yet. In my existing project, they've used CFTransaction for concurrency but those issues are still happening whatever they've used it in. That's why I need to check which one is suitable for concurrency.

I've created three files for testing purpose. There are index.cfm, cflock.cfm and cftransaction.cfm.

index.cfm

view plain print about
1[iframe src="cftransaction.cfm?getID=1" width="500" height="150"][/iframe]
2[iframe src="cftransaction.cfm?getID=2" width="500" height="150"][/iframe]
3[iframe src="cftransaction.cfm?getID=3" width="500" height="150"][/iframe]

[More]

Why Coldfusion 9 cannot connect SQL 2005 Express?

In my life, mySQL database is very touch to use. Because it's very complicated to add or remove data column, rename the table name and inserting demo data without installing phpMyAdmin. That's why I decided to remove mySQL as my project database and to install SQL 2005 server Express version.

So, download both of SQL 2005 Server and also management studio express version. Honestly, installing of SQL 2005 express version is very simple and easy. Because, my before time I've used to develop Coldfusion Project with SQL server. That's why I can say it's simple. Unfortunately, I encountered the following error when I tried to connection SQL 2005 server in Coldfusion Administrator.

[More]

Multiple Area Chart between CFChart and HighCharts

Sometimes, I'm really getting sick of using CFChart because it doesn't support all of Charting features like Pyramid Chart without integrating Web3Dchart. Even integrate with Web3Dchart, it's not good enough to use like Fushion Chart. That's why I was seeking the nice 3rd party chart like jQtouch. Fortunately, I found that HighCharts fully support what I really need it. That's is Area Chart. Because I'm currently developing Growth Chart feature for our current Project.

Using Multiple Area Chart with CFChart is I've already described in my older posts. Please check it out the following link http://www.ppshein.net/index.cfm/2011/1/22/Multiple-Area-Chart-in-Coldfusion

view plain print about
1<cfchart
2    chartheight="200"
3    chartwidth="300"
4    xaxistitle="Year"
5    yaxistitle="Month"
6    format="png">

7        <cfchartseries type="area">
8            <cfchartdata item="10" value="40">
9            <cfchartdata item="20" value="50">
10        </cfchartseries>
11        <cfchartseries type="area">
12            <cfchartdata item="30" value="80">
13            <cfchartdata item="40" value="90">
14        </cfchartseries>
15</cfchart>

[More]

How to avoid using Trunc Function in Oracle

There are so many Date Function in Oracle. Some are very efficient to use when filtering date and others are not quite suitable to use for Oracle Tuning. Among them, Trunc function isn't good enough to use for Oracle Tuning. The description of the Trunc function returns a date truncated to a specific unit of measure.

How does Trunc function work? It's a bit complicated to describe how Trunc works. The fastest way to describe is "it collect all of (selected) records from table and change Date Format. So, when we use Trunc function, Oracle must do those process."

The following coding is I've wrote when I didn't consider for Oracle tuning.

view plain print about
1<cfquery name="getResult" datasource="mydsn">
2    SELECT user_id, user_name, user_rank FROM tblLogs
3    WHERE user_login_time <= <cfqueryparam
4                                value="#from_date#"
5                                cfsqltype="cf_sql_varchar">
6    AND user_login_time >= <cfqueryparam
7                                value="#to_date#"
8                                cfsqltype="cf_sql_varchar">
9</cfquery>

Above coding, user_login_time has been saved as SYSDATE of Oracle. That's why current date and time have been included in user_login_time. So, I must need to use Trunc function to change Date format from Date/time format. If I do so, Oracle collect all data from tblLogs table and change format to Date string then get records by from_date and to_date. So, it's not good if our table has over 1 million records.

How to avoid using Trunc function for filter our date/time data field? It's very simple. Please see the following coding.

view plain print about
1<cfquery name="getResult" datasource="mydsn">
2    SELECT user_id, user_name, user_rank FROM tblLogs
3    WHERE user_login_time <= <cfqueryparam
4                                value="#from_date#"
5                                cfsqltype="cf_sql_varchar">
6    AND user_login_time > to_date(<cfqueryparam
7                                    value="#to_date#"
8                                    cfsqltype="cf_sql_varchar">, 'MM-DD-YY') + 1
9</cfquery>

How to give a name to your website

I admit this post isn't quite relevant to Coldfusion but it will be useful to anyone who is planning to give a name for website and doing for startups. I still remember the following useful information from my ex-boss who did presentation for the new website. In this presentation, he told as follow:

If we need to give a name for website, it should be aware of following facts

  • your website name should be short and easy to memorize like Google, Yahoo, Bing, Facebook and so on
  • All of navigation at your website should be useful.
  • Always need to put Home Page navigation link should be at the top of your website.
  • Need to make our customers not to lose way when browsing.
  • Need to put report button for broken links.
  • Should not use heavy image file for every pages.

That's all I still remember from him.

Change BlogCFC tweetbacks function

Yesterday night, I was troubleshooting why my tweetbacks aren't coming out even they're in Twitter. I've asked Ray about this problem and he told me that previous version of BlogCFC is completely working for tweetbacks but in current version, it doesn't work at all. That's why I was troubleshooting on SweetTweets.cfc and make complicated testing. Finally, I found it's because getShortURLs function of it. In blogCFC infrastructure, it posts blog URL into getShortURLs function and which will make the short URLs and search those short URLs in twitter by getTweetSearchUrl function. So, getTweetSearchUrl found no records for my short URLs in twitter. That's why I've changed not to make short URLs and search Original URLs in twitter and found some of results from twitter as jSON format data.

[More]

Top of Page