Tuesday, December 1, 2009

Google Map Tutorial

http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx

Google Map API Excmple

http://esa.ilmari.googlepages.com/

Javascript Beautifier

http://jsbeautifier.org/

Singleton pattern

In software engineering, the singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects (say, five). Some consider it an anti-pattern, judging that it is overused, introduces unnecessary limitations in situations where a sole instance of a class is not actually required, and introduces global state into an application.

http://en.wikipedia.org/wiki/Singleton_pattern

COMET: Multi-Client continuous PUSH-update Grid for ASP .net Web Apps

http://www.codeproject.com/KB/aspnet/CometMultiClient.aspx

Saturday, November 28, 2009

Remove null element in PHP array and reorder

<?php

$my_array = array(5, "abc", null, 2.5, NULL, 0, "", false, 8);
print_r($my_array);


function is_notnull($v) {
return !is_null($v);
}

$remove_null_array = array_filter($my_array, "is_notnull");// remove null element
echo "<p>remove_null_array:<br />";
print_r($remove_null_array);

$reordered_array = array_values($remove_null_array);
echo "<p>reordered_array:<br />";
print_r($reordered_array); // reorder the array values

Wednesday, November 25, 2009

Inversion of control

Inversion of control, or IoC, is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming.

http://en.wikipedia.org/wiki/Inversion_of_control

http://caterpillar.onlyfun.net/Gossip/SpringGossip/IOC.html

http://msdn.microsoft.com/en-us/library/cc707904.aspx

Tuesday, November 24, 2009

What does document.domain = document.domain do?

http://stackoverflow.com/questions/1481251/what-does-document-domain-document-domain-do

I encounter a domain problem today and finally get it work by
document.domain = document.domain

Also, if you press the back button, the onload event of iframe will be faster than that of the parent frame and may cause permission denied error. The solution to this is to setTimeout and use the try-catch loop.

Eyeblaster Creative Zone

http://creativezone.eyeblaster.com/

Wednesday, November 18, 2009

Using SharePoint and log4net in harmony

http://www.codeproject.com/KB/sharepoint/SharepointLog4Net.aspx

ASP.NET MVC

http://weblogs.asp.net/shijuvarghese/archive/2008/07/09/asp-net-mvc-vs-asp-net-web-form.aspx

SQL Server Integration Services

http://msdn.microsoft.com/en-us/library/ms141026%28lightweight%29.aspx

JSON hi-jacking

http://hackademix.net/2009/01/13/you-dont-know-what-my-twitter-leaks/

Database Connection Pool

In software engineering, a connection pool is a cache of database connections maintained by the database so that the connections can be reused when the database receives future requests for data. Connection pools are used to enhance the performance of executing commands on a database. Opening and maintaining a database connection for each user, especially requests made to a dynamic database-driven website application, is costly and wastes resources. In connection pooling, after a connection is created, it is placed in the pool and it is used over again so that a new connection does not have to be established. If all the connections are being used, a new connection is made and is added to the pool. Connection pooling also cuts down on the amount of time a user must wait to establish a connection to the database.

http://en.wikipedia.org/wiki/Connection_pool

http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx

Factory Method Pattern

The factory method pattern is an object-oriented design pattern. Like other creational patterns, it deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The factory method design pattern handles this problem by defining a separate method for creating the objects, whose subclasses can then override to specify the derived type of product that will be created. More generally, the term factory method is often used to refer to any method whose main purpose is creation of objects.

http://en.wikipedia.org/wiki/Factory_method_pattern

http://lennilobel.wordpress.com/2009/08/06/leveraging-polymorphism-with-factory-classes/

http://dofactory.com/Patterns/PatternFactory.aspx

Tuesday, November 10, 2009

IE6 png fix

Javascript method (modified from source: http://homepage.ntlworld.com/bobosola)

function pngfix() {
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (version < 7.0) && (document.body.filters)) {
for (var i = 0; i < document.images.length; i++) {
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = " + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\">
"
img.outerHTML = strNewHTML
i = i - 1
}
}
}
}

function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof (window.onload) != 'function') { window.onload = func; }
else { window.onload = function() { oldonload(); func(); } }
}

addLoadEvent(pngfix);


2. CSS method:
#template
{
_background-image: none;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../images/guide2.png', sizingMethod='scale');
}

Monday, November 9, 2009

More in request form

http://wiki.developers.facebook.com/index.php/Talk:Fb:request-form

Thursday, November 5, 2009

Reading a file content

Use this code:
StreamReader sr = new StreamReader(Server.MapPath("xxx.txt"));
string m_sOutput = sr.ReadToEnd();

Facebook Application Box Development

To Add application box to Wall and Info Tab/Box Tab:
http://wiki.developers.facebook.com/index.php/Using_profile_setFBML

API: http://wiki.developers.facebook.com/index.php/Profile.setFBML
Future: http://apps.facebook.com/comicbooks/screencasts/New-Profile-1

1. You need to first call the profile.setFBML
http://wiki.developers.facebook.com/index.php/Profile.setFBML

For updating profile box (dynamic content), use
http://fbcookbook.ofhas.in/2009/02/04/updating-profile-box-using-fbref/

More posts:
http://forum.developers.facebook.com/viewtopic.php?id=26910
http://forum.developers.facebook.com/viewtopic.php?id=31613


2. And then add the Add to Profile button for users to click on it
http://wiki.developers.facebook.com/index.php/Fb:add-section-button
Another method to add the "add to profile" button:
http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Connect.ShowAddSectionButton

FB.Connect.showAddSectionButton("profile", document.getElementById("addProfileButton"));

You need to induce users to click on the button:
http://forum.developers.facebook.com/viewtopic.php?pid=153464


3. Show different info. according to whether the user adds the profile box

Still looking at the info below


http://forum.developers.facebook.com/viewtopic.php?id=36196

http://forum.developers.facebook.com/viewtopic.php?id=33809

http://forum.developers.facebook.com/viewtopic.php?pid=49318

http://wiki.developers.facebook.com/index.php/Talk:Profile.setFBML#How_to_update_profiles_of_all_users_who_installed_your_app.3F

Facebook Stream.publish

Facebook issues new Open Stream API and the feed template is now deprecated.

Use this in backend:
http://wiki.developers.facebook.com/index.php/Stream.publish

Use this in iframe or facebook connect page:
http://wiki.developers.facebook.com/index.php/FB.Connect.streamPublish

Using the open stream API:
http://wiki.developers.facebook.com/index.php/Using_the_Open_Stream_API



http://wiki.developers.facebook.com/index.php/Attachment_%28Streams%29

Tuesday, November 3, 2009

Scale images in ASP.net

Using this code:

static System.Drawing.Image Scale(System.Drawing.Image imgPhoto, int v_iPercent)
{
int destWidth = (int)(imgPhoto.Width * v_iPercent / 100.0);
int destHeight = (int)(imgPhoto.Height * v_iPercent / 100.0);
Bitmap bmPhoto = new Bitmap(imgPhoto, destWidth, destHeight);
return bmPhoto;
}

MVC

http://msdn.microsoft.com/en-us/library/ms978748.aspx

Facebook Fan page customization

http://thinkdiff.net/facebook/customize-facebook-fan-page-by-static-fbml-app/


http://thinkdiff.net/facebook/develop-customize-facebook-application-for-fan-page/


http://www.snipe.net/2009/10/mini-site-facebook-static-fbml/

Wednesday, October 28, 2009

Cannot find System.Globalization.CultureAndRegionInfoBuilder??

Kindly add reference and choose sysglobl under the .NET tab.

Thursday, October 22, 2009

Resizing a Photographic image with GDI+ for .NET

http://www.codeproject.com/KB/GDI-plus/imageresize.aspx

Channel 9 learning center

http://channel9.msdn.com/learn/

Flash cannot read a plain text file directly

Today, I knew that flash cannot read a plain text file directly.

The file content has to be:
1. variable format
value=32
2. xml format
<xml>32<xml>

but not only "32".

At least, I can't find any way to do that using AS2 now.

For as3 to read a file, you can look at the following link:
http://www.thekuroko.com/2007/05/26/reading-a-file-with-actionscript-3/

Wednesday, October 21, 2009

Check whether children elements exceed the overflow parent

<div id="f" style="overflow: hidden; background-color: red; width: 300px; height: 300px;">
<div id="s" style="background-color: green; width: 350px; height: 300px;">
</div>
<script><br />if (f.scrollWidth > f.clientWidth){<br />alert("overflowed");<br />}<br /></script></div>

Monday, October 19, 2009

Javascript Toolbox

http://www.javascripttoolbox.com/

Get user list of facebook application

There is no way for us to get a list of users of an application.
You have to store it in your own database.

Thursday, October 15, 2009

Facebook API call usage

Get photos of a user

IList photos = API.photos.get(API.users.getLoggedInUser().ToString(), "", new List());

FQL equivalent:
public static T Deserialize(string json)
{
T obj = Activator.CreateInstance();
MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json));
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
obj = (T)serializer.ReadObject(ms);
ms.Close();
return obj;
}
[DataContract]
public class Photo{
[DataMember]
public string src_big { get; set; }
};

protected void btnFromAlbum_Click(object sender, ImageClickEventArgs e)
{

panelImage.Visible = true;
fql qPhotos = new fql(API);
qPhotos.UseJson = true;
string result = qPhotos.query(string.Format("select src_big from photo where pid in (SELECT pid FROM photo_tag WHERE subject={0})", API.users.getLoggedInUser()));

List photos = Deserialize>(result);
litTest.Text = photos.Count.ToString();
lvPhotos.DataSource = photos;
lvPhotos.DataBind();
}

Steps for using XFBML

http://wiki.developers.facebook.com/index.php/XFBML

Using XFBML for prompt permission
Constraint: The action needs to be initiated by user
Would you like to receive email from our application?

To do it automatically, using JS API instead.

AJAX Requests in a Facebook Iframe Application

http://www.keywordintellect.com/facebook-development/how-to-run-simple-ajax-requests-in-a-facebook-iframe-application/

http://www.keywordintellect.com/facebook-development/facebook-iframe-authentication-across-pages-ajax-requests/

Wednesday, October 14, 2009

Facebook Authorizing Applications

http://wiki.developers.facebook.com/index.php/Authorizing_Applications

Using Facebook Developer Toolkit CanvasIFrameBasePage
The allow access popup will appear automatically.

Online VisualStudio IDE

http://www.coderun.com/ide/

IFrame vs FBML Facebook pages

Choosing between an FBML or IFrame Application
http://wiki.developers.facebook.com/index.php/Choosing_between_an_FBML_or_IFrame_Application

http://www.stevetrefethen.com/wiki/Facebook%20application%20development%20in%20ASP.NET.ashx

http://www.stevetrefethen.com/blog/DevelopingFacebookApplicationsInCWithASPNET.aspx

Resizable IFrame
http://wiki.developers.facebook.com/index.php/Resizable_IFrame

Required by resizable IFrame
http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel

IFrame Resize Demo
http://apps.facebook.com/wzhu_public_resize/

IFrame Url
http://wiki.developers.facebook.com/index.php/IFrame_Url

http://developers.facebook.com/news.php?blog=1&story=152

===========================================================================
Using IFrames in FBML Canvas Pages and FBML in IFrames

If you're using FBML for your canvas pages and you decide you want one of your pages to be rendered in an IFrame, don't use fb:iframe for that. Instead, you should use the fb_force_mode querystring parameter to switch modes which will accomplish the same thing without incurring a round trip to your server just to fetch the fb:iframe tag.

Similarly, if you are using IFrames for your application but want some particular page to be an FBML page, you can use fb_force_mode to force a switch to FBML. If you find documentation that advises using fb:iframe for switching from FBML to IFrame mode, it was probably written before fb_force_mode was released; we should have all those instances cleaned up soon.

Common and Useful Database Design


http://www.dotblogs.com.tw/ajun/archive/2008/08/05/4816.aspx

做為一個寫程式的,開開資料結構是很平常的事,
但有時,我們總是會希望可以有方法驗證一下我們這樣的設計是不是真的合適,
通常我們是在系統跑了一段時候後才發現,少考慮了一些欄位,
不過這個還算小事,
有時因為需求的遺漏未考慮周全,結果卻要重新設計整個結構,那才是真正糟糕的.

現在有個網站 DatabaseAnswers.org 提供了超過500個資料結構的模型,
讓我們可以參考,

其中排行前二十名的如下

  1. Libraries and Books
  2. Inventory Control for Retail Stores
  3. Hotel Reservations
  4. Video Rentals
  5. School Management
  6. Clients and Fees
  7. CD Collections
  8. Customers and Invoices
  9. Payroll
  10. Apartment Rentals
  11. Customers and Services
  12. ERP
  13. Car Sales
  14. Customers and Addresses
  15. Driving Schools
  16. Health and Fitness Clubs
  17. Hospital Admissions
  18. Inventory of Files in Boxes
  19. Sports Clubs
  20. Airline Reservations

而該作者(Barry Williams)所製作資料模型也被Microsoft SQL Server 2005 Express 做為Starter Database Schemas推廣.
另外該作者也做了教學影片(Understanding a Database Schema)給初學者.

http://www.dotblogs.com.tw/ajun/archive/2008/08/05/4816.aspx

ListView with own datasource and datapager

If you find that you need to click the page number twice to change page, please look at the following code:

http://forums.asp.net/t/1215848.aspx

Job Seekers: How to Tell Stories to Stand Out

http://www.cio.com/article/print/491747

Linq on DataTable Query

Today I have to serialize the DataTable to JSON.
I get the cyclic reference error using the following code:
string example = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(dt);

After googling, I find that we cannot serialize a dataTable directly using the JavaScriptSerializer provided. Some webs implement their own code for dataTable.

But I finally have a fine solution - use Linq to Query DataTable:
string example = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(dt.AsEnumerable());

Also if you just want specific columns, you can do the following query:
var dataToSerialize = from p in ct.AsEnumerable()
select new{ Column1 = c.Field("c1");}

Reference:
http://blogs.msdn.com/adonet/archive/2007/01/26/querying-datasets-introduction-to-linq-to-dataset.aspx

Friday, October 9, 2009

jqZoom and mousewheel js event

http://www.mind-projects.it/projects/jqzoom/demos.php#demo1


mousewheel in javascript:
http://adomas.org/javascript-mouse-wheel/

Google Maps API Examples and Test Pages

http://koti.mbnet.fi/ojalesa/exam/

Apache PDFBox - PDF version 1.5

Anyone working with lucene that may use Apache PDFBox library to extract text from PDF for indexing. However, the official build was unable to index PDF file version 1.5 and 1.6. Here is the fix for the issue.

1. Download the latest PDFBox 0.8.0 from http://incubator.apache.org/pdfbox/download.html#pdfbox. Please download pdfbox-0.8.0-incubating-src.jar.
2. Extract the jar and open the java file src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java.
3. Modify line 100 to look like
while(pdfSource.available() > 0 && objIter.hasNext())
4. Run ant to build the project and get the pdfbox-0.8.0-incubating.jar from target folder
Reference:
http://issues.apache.org/jira/browse/PDFBOX-533

Thursday, October 8, 2009

Introduction to PayPal for C# - ASP.NET developers

http://www.codeproject.com/KB/aspnet/paypal_c_aspnet.aspx

Thursday, September 24, 2009

OledbException: " Data type mismatch in criteria expression"

This exception happens today when I have columns with characters "." (Dot) or "-" (Hyphen).

Try to avoid this if possible.

Monday, September 14, 2009

Select 30% of records randomly in SQL Server

select top 30 percent * from [table_name] ORDER BY NEWID()

select 30% of records of last month

select top 30 percent * from[table_name]
and DatePart(""m"", date_created) = DatePart(""m"", DateAdd(""m"", -1, getdate()))
AND DatePart(""yyyy"", date_created) = DatePart(""yyyy"", DateAdd(""m"", -1, getdate()))
ORDER BY NEWID()

Sunday, September 13, 2009

HttpContext.Current.Cache.Insert

HttpContext.Current.Cache.Insert

this.Page.ClientScript.RegisterClientScriptBlock

Sunday, August 30, 2009

Rolling with Ruby on Rails

http://oreilly.com/ruby/archive/rails.html

http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials

Identifying and non-identifying relationships

http://stackoverflow.com/questions/762937/whats-the-difference-between-identifying-and-non-identifying-relationships

http://www.datanamic.com/support/relationshiptypes.html

Writing jQuery Plugin

http://www.easyjquery.com/jquery-plugins/how-to-write-jquery-plugin


http://blog.jeremymartin.name/2008/02/building-your-first-jquery-plugin-that.html


http://mattberseth.com/blog/2008/06/glowbuttons_writing_my_first_j.html

Sort JSON by its key(properites)

Today, I need to sort the JSON by its key(properties) and I write the following extended function to array element.

Array.prototype.extendSort = function(field,desc){
function sortField(a,b){
if (a[field] == b[field]){
return 0;
}
var result = a[field] > b[field]?1:-1;
if (desc == true) result=result*-1;
return result;
}
this.sort(sortField);

}
var testjson = [{"id":3, "name":"Charlie"},{"id":5, "name":"Danny"},{"id":4, "name":"Billy"}]
testjson.extendSort("id", false);

PS:
If you want to loop through the array using for...in statement, you may find that the extendSort also recognizes as one of the object.

You should use the following code to deal with that:
for (name in testjson) {
if (testjsonj.hasOwnProperty(name)) {
...
}
}

Friday, August 28, 2009

Wednesday, August 26, 2009

Send email to a folder instead of SMTP server when testing

While testing, you can have emails sent to a folder on your computer instead of an SMTP server. Put this in your web.config:

<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\Temp\" />
</smtp>
</mailSettings>
</system.net>



http://stackoverflow.com/questions/54929/hidden-features-of-asp-net

Thursday, August 20, 2009

Get QueryString by javascript

function QueryString(name) {
var AllVars = window.location.search.substring(1);
var Vars = AllVars.split("&");
for (i = 0; i < Vars.length; i++) {
var Var = Vars[i].split("=");
if (Var[0] == name) return Var[1];
}
return "";
}

Thursday, August 13, 2009

Javascript date validation

Very simple:

function isValidDate(year, month, day) {
var date = new Date(month + "/" + day + "/" + year);
return date.getDate() == day && date.getMonth() == month - 1 && date.getFullYear() == year;
}

Wednesday, August 12, 2009

Write Permission Deployment Problem

Just ask the server admin to deploy the file and grant the write access to a folder. But the program still shows the access denied error.

The possible cause:
1. The file is already there and cannot be overwritten even the permission is set.

JSON and ASP.NET

http://geekswithblogs.net/JuanDoNeblo/archive/2007/10/22/json_in_aspnetajax_part1.aspx

http://dineshmandal.wordpress.com/2009/07/25/jquery-json-asp-net-web-service/

window.onbeforeunload

https://developer.mozilla.org/en/DOM/window.onbeforeunload

IIncorrect MIME Type for CSS Files

今日deploy 左一堆file 上server,點知啲page 係IE 上面show 係正常,FF, Chrome, Safari 等其他browser 就讀唔到個 css file。

Firebug 出左呢一句:
The resource from this URL is not text: ................/xxx.css

搵左一輪都未知乜野事,跟住諗下會唔會同Server 有關,係Fiddler 發現佢用Sun one web server,然後就用sun one web server load css 係Google search,跟住發現好有可能同CSS MIME Type 有關:

http://forums.sun.com/thread.jspa?threadID=5011423

其中一個reply:
The problem is very likely with the CSS MIME type.

Take a look at the archives for this newgroup for solutions and workarounds.

Fiddler check 到個 Content-type: application/x-pointplus。

然後用css mime type x-pointplus 再搵,第一個search result 就係Firefox official doc:
https://developer.mozilla.org/en/Incorrect_MIME_Type_for_CSS_Files

https://developer.mozilla.org/en/Properly_Configuring_Server_MIME_Types

P.S.:原來係 Web Developer Plugin 寫住:
Error: The stylesheet http://stage.acuvue.com.hk/include/css/acuvue.css was not loaded because its MIME type, "application/x-pointplus", is not "text/css".

Tuesday, August 11, 2009

Best Practices for Using ADO.NET

Good Article of ADO.NET

http://msdn.microsoft.com/en-us/library/ms971481.aspx

SqlDataReader.Close Method

You must explicitly call the Close method when you are through using the SqlDataReader to use the associated SqlConnection for any other purpose.

The Close method fills in the values for output parameters, return values and RecordsAffected, increasing the time that it takes to close a SqlDataReader that was used to process a large or complex query. When the return values and the number of records affected by a query are not significant, the time that it takes to close the SqlDataReader can be reduced by calling the Cancel method of the associated SqlCommand object before calling the Close method.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.close.aspx

Monday, July 27, 2009

Language codes for different countries

http://babelwiki.babelzilla.org/index.php?title=Language_codes

10 skills developers will need in the next five years

http://blogs.techrepublic.com.com/10things/?p=643

A few measures that speed up your visual studio

http://labs.episerver.com/en/Blogs/Steve-Celius/Dates/112266/6/Speed-up-Visual-Studio/
http://blog.miniasp.com/post/2008/04/speed-up-visual-studio-performance-and-increase-work-efficiency.aspx
http://weblogs.asp.net/scottgu/archive/2006/09/22/Tip_2F00_Trick_3A00_-Optimizing-ASP.NET-2.0-Web-Project-Build-Performance-with-VS-2005.aspx
http://dan9298.blogspot.com/2009/01/visual-studio-and-auto-toolbox-populate.html

Tuesday, July 21, 2009

TSQL Union and Union ALL

Union will select distinct values where Union ALL will not

Thursday, July 16, 2009

The Open Source Opportunity

http://webworkerdaily.com/2009/07/15/the-open-source-opportunity/

Monday, July 6, 2009

Materials for Comet

http://stackoverflow.com/questions/1086380/how-does-facebook-gmail-send-the-real-time-notification/1086448#1086448
http://stackoverflow.com/questions/136012/comet-and-jquery
http://ajaxpatterns.org/HTTP_Streaming
http://plugins.jquery.com/project/Comet
http://www.nabble.com/jQuery-Doing-Comet-td18120554s27240.html
http://www.pathf.com/blogs/2007/04/roundup_comet_t/

Sunday, July 5, 2009

jQuery modal plugin

I have tried to use different jQuery modal plugin to finish my job these days.
What I want is add a half-transparent overlay to the background and popup a dialog box to ask some questions.
Some plugins are too complex, hard to use or buggy:
Thickbox - cannot retain the radiobutton or checkbox answer in IE6,7 after closing the dialog.
BlockUI - hard to make the position right

And I finally use the jqmodal plugin (very easy to use):
http://dev.iceburg.net/jquery/jqModal/

Materials for MySQL Database

A Technical Tour of MySQL
http://www.devshed.com/c/a/MySQL/A-Technical-Tour-of-MySQL/

MyISAM vs InnoDB
http://stackoverflow.com/questions/20148/myisam-versus-innodb

MySQL performance blog
http://www.mysqlperformanceblog.com/?s=MyISAM+InnoDB

How do you choose a MySQL database engine
http://serverfault.com/questions/219/how-do-you-choose-a-mysql-database-engine

Transaction and autocommit
http://www.oreillynet.com/databases/blog/2007/02/mysql_transactions_and_autocom.html

log file in MySQL DB

MySQL server log

http://dev.mysql.com/doc/refman/5.0/en/server-logs.html

The error log
Problems encountered starting, running, or stopping mysqld
log_error = [filename]

The general query log (recommended!)
Established client connections and statements received from clients
log = [filename]

The binary log
All statements that change data (also used for replication)
log_bin = [filename]

The slow query log
All queries that took more than long_query_time seconds to execute or didn't use indexes
log_slow_queries = [filename]
long_query_time = 2 (Time you think that the query takes too long)

Transaction in Zend Framework

http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.transactions

The MyISAM engine doesn't support transaction.
You may need to use InnoDB instead.
Read the following post for my question:
http://stackoverflow.com/questions/1083857/cannot-rollback-transaction-in-zend-framework


Thursday, July 2, 2009

jQuery issue

I have to do a survey that will dim the bg and popup a box to ask questions.

I use thickbox to do the effect, but to match the ui, I have to edit the js and css to remove the padding.

Problem:
"nested form element" which occurs in dynamic page so that I cannot append item and serialize the form correctly.

Solution:
Use a temp. form to solve the problem:
$("<form></form>").append($("#form_inside")).serialize()

Wednesday, July 1, 2009

Expected Salary?

http://discuss.joelonsoftware.com/default.asp?joel.3.603939.20

What is your expected salary? Dodging that awkward interview question...

http://www.careerslave.com/interview-advice/what-is-your-expected-salary-dodging-that-awkard-interview-question/


“What are your salary expectations?”

Not an easy question to answer at your interview - as I’ve looked at other tough interview situations over the past few weeks (such as “reasons for leaving your job“), I thought it was worth covering how to deal with being asked what salary you expect to get.

First of all, you need to know that you don’t have to disclose your current or past salaries and you don’t need to respond to this question. But given you are interviewing for a new job, the manner in which you deal with the question can affect the outcome of the interview, so it is worth being prepared.

In a lot of cases, especially early on in your career, you will be expecting an increase in salary when you move to a new job - usually because the new job may be a step up for you and as such has more responsibilities.

You also need to remember that your new employer really has no way of finding out your previous salary, so if you want to exaggerate a little to help justify an increased expected salary, then feel free to do so - it’s not a big deal, but please do be conscious that you shouldn’t go to far with this. Adding a couple more £k to your current salary isn’t a big deal.

How to respond when asked what your salary expectations are

Let’s assume you want more money than you are getting just now. If the salary hasn’t been disclosed for the job, then you need to carefully discuss the potential with your new employer.

You can start off by saying something along the lines of, “Well, obviously I would expect a salary that is in line with the level and responsibilities of the job and my experience - what starting salary do you offer for this job role?” - this is a great counter to the question. It doesn’t commit you to a specific figure, and moves the discussion back to them. They will always have a figure in mind from the start of the interview - most employers just want to see if they can hire you for less money! :)

There are several responses they can give to this:

  • A figure that is way less than you want (in which case you need to think about if the job is really suitable for you)
  • A figure that is a little lower than you want (then you need to put an argument forward for a higher starting salary)
  • A figure that is suitable or higher than expected (take it - or haggle some more if you’re feeling cheeky!).

How to haggle for more money

It isn’t easy and you could quite easily mess up the entire interview if you go to far with this - all the same, it is worth it in many cases - you should take whatever chances you can to improve your own person situation.

There are several arguments you can give:

  • I would have expected a higher starting salary for this position
  • My current salary is higher than that
  • That salary is a little lower than I think I need right now
  • I think my experience would warrant a higher salary than that

Regardless of the approach you take, you should always end it with a question. You do not want to put forward a staunch argument with no scope of discussion - you need to keep the discussion moving in your favour by always giving your interview a tight breadth to respond (rather than leaving the conversation wide open which could result in them changing the subject).

Your goal should be to maintain control of the discussion until it is resolved in your favour - the danger is that you can come across as to stubborn / greedy / etc so it is worth preplanning your approach.

Good luck!



Job Offer Salary Negotiation
http://www.cvtips.com/job_offer_salary_negotiation.html

Thursday, June 25, 2009

10 UI Design Patterns You Should Be Paying Attention To

http://www.smashingmagazine.com/2009/06/23/10-ui-design-patterns-you-should-be-paying-attention-to/

ASP.net DataContractJsonSerializer

DataContractJsonSerializer in .NET 3.5
http://www.west-wind.com/WebLog/posts/218001.aspx

Use LINQ and .NET 3.5 to Convert RSS to JSON
http://blogs.msdn.com/kaevans/archive/2007/09/04/use-linq-and-net-3-5-to-convert-rss-to-json.aspx

Converting Data to JSON in .NET Framework 3.5
http://blogs.msdn.com/vijay/archive/2007/10/04/converting-data-to-json-in-net-framework-3-5.aspx

DataContractJsonSerializer Class
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer(VS.95).aspx

Tip/Trick: Building a ToJSON() Extension Method using .NET 3.5
http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx
==========================================================
Following error occurs:
"Object graph for type X contains cycles and cannot be serialized if reference tracking is disabled."

Set dbml class "Serialization mode" to unidirectional
Use DataLoadOptions with the DataContext before executing the linq command

Returning LINQ to SQL Entities from a WCF Service
http://www.codeexperiment.com/post/Returning-LINQ-to-SQL-Entities-From-WCF.aspx

Monday, June 22, 2009

Import Excel Sheet to MSSQL2005

I have a problem importing an excel sheet to MSSQL2005.

I use oledbadapter to import the excel sheet. The problem is that some fields which are numbers disappear when I fill the datatable.

Solution:
Use the IMEX=1 in the connectionstring.
Also make sure that the format of the column is "General" as exponential number will be used if the format is "Text".

Monday, June 8, 2009

Google Earth - Shelter Competition

http://sketchupdate.blogspot.com/2009/06/announcing-design-it-shelter.html

Thursday, June 4, 2009

SharePoint Interview Questions

http://www.scribd.com/doc/4729115/SharePoint-Interview-Questions

Monday, June 1, 2009

Diaster Recovery Planning

http://en.wikipedia.org/wiki/Disaster_recovery

http://www.utoronto.ca/security/documentation/business_continuity/dis_rec_plan.htm

https://wiki.internet2.edu/confluence/display/secguide/Disaster+Recovery+Planning+Guide

Sunday, May 31, 2009

Solution if only part of tiles (grey area appear) are shown in Google map

1. Set the doctype correctly according to the Google API.
2. Run the initialize method as the window.onload function.

Thursday, May 28, 2009

setting of htaccess

1. php_flag register_globals off
instead of just by $abcif this flag sets to off, program will be only able to get the $_GET["abc"], $_POST["abc"],etc if the url is url.html?abc=123

2. php_flag magic_quotes_gpc off
This flag is used to originally give backslash to gpc(get, post, cookie) to prevent SQL injection.

3. php_flag short_open_tag on
Allow the use of short open tag < ? instead of < ?php

4. Options -Indexes
Disallow directory browsing

5. DirectoryIndex index.php index.htm index.html
If the user types the directory name, we search through the list of index.php to show it.

Wednesday, May 27, 2009

Tuesday, May 26, 2009

JQuery Plugin List

jQuery UI:
http://jqueryui.com/demos/

jQuery Ribbon
http://dev.mikaelsoderstrom.se/scripts/jquery/ribbon/
http://jqueryribbon.codeplex.com/

jCarousel:
http://sorgalla.com/projects/jcarousel/

Lightbox:
http://www.balupton.com/sandbox/jquery_lightbox_bal/demo/
http://plugins.jquery.com/project/jquerylightbox_bal

Facebox:
http://famspam.com/facebox

BlockUI
http://malsup.com/jquery/block/

ThickBox
http://jquery.com/demo/thickbox/

tablesorter
http://demos.flesler.com/jquery/scrollTo/
http://flesler.blogspot.com/2007/10/jqueryscrollto.html

AutoComplete
http://jquery.bassistance.de/autocomplete/demo/
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

Facebook style autocomplete
http://web2ajax.fr/examples/facebook_searchengine/

Accordion
http://jquery.bassistance.de/accordion/demo/

TreeView
http://jquery.bassistance.de/treeview/demo/

InnerFade
http://medienfreunde.com/lab/innerfade/

Tooltip
http://jquery.bassistance.de/tooltip/demo/
http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/

Cycle
http://www.malsup.com/jquery/cycle/

Menu
http://be.twixt.us/jquery/suckerFish.php

Validation
http://jquery.bassistance.de/validate/demo/
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Pagination
http://d-scribe.de/webtools/jquery-pagination/demo/demo_options.htm
http://plugins.jquery.com/project/pagination


Sites containing plugin list:
http://www.open-open.com/ajax/2_jQuery.htm

Useful CodeProject Tutorial

GeoPlaces : hybrid smart client, involving RESTful WCF/WPF and more
http://www.codeproject.com/KB/smart/GeoPlaces.aspx


ASP.NET AJAX Control Toolkit ModalPopupExtender Control in Action
http://www.codeproject.com/KB/ajax/ASPModalInAction.aspx

Top 10 steps to optimize data access in SQL Server

Top 10 steps to optimize data access in SQL Server
Part I:
http://www.codeproject.com/KB/database/OptimizeDBUseIndexing.aspx
Part II:
http://www.codeproject.com/KB/database/RefactorTSQLs.aspx
Part III:
http://www.codeproject.com/KB/database/IndexAndDenormalize.aspx

TechCrunch

http://www.techcrunch.com/

Wednesday, May 20, 2009

First-time project managers need failures

One of the greatest impediments to first-time project managers' success is their need to succeed. There are three things they really need--and early success isn't one of them.

http://www.zdnetasia.com/techguide/techmanagement/0,39044902,62054210,00.htm?scid=nl_z_tgtm

Thursday, May 14, 2009

Database Publishing Tools

Database Publishing Wizard http://www.codeplex.com/sqlhost/Wiki/View.aspx?title=Database%20Publishing%20Wizard

SQL Dumper
SQL Server Dumper enables you to dump selected SQL Server database tables into SQL INSERT statements, that are saved as local .sql files and contain all the data required to create a duplicate table, or to be used for backup purposes. You can choose to create an individual .sql file for each table, or combine all selected tables into a single file.

http://www.ruizata.com/

Wednesday, May 13, 2009

Get Url without Querystring and UrlBuilder

Request.Url.GetLeftPart(UriPartial.Path)

Use UrlBuilder class to build url instead of string concatenation.

Monday, May 11, 2009

Add a default time and make the dropdownlist required (not include that item)

Add a dropdownlist with the value of default item=0:
<asp:dropdownlist id="ddlExample" runat="server" appenddatabounditems="true">
<asp:listitem text="select" value="0"></asp:listitem>
</asp:dropdownlist>

Add a requiredfieldvalidator with the initialvalue=0:

<asp:requiredfieldvalidator id="rfvExample" runat="server" initialvalue="0" controltovalidate="ddlExample" text="select plz">
</asp:requiredfieldvalidator>

2009 Google Flash SEO

http://www.beussery.com/blog/index.php/2008/10/google-flash-seo/

Webmaster guidelines

http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=35769

Saturday, May 2, 2009

XSS (Cross Site Scripting) Prevention Cheat Sheet

http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet

Wednesday, April 29, 2009

The latest from Facebook: 'Open Stream API'

The latest from Facebook: 'Open Stream API'
By Caroline McCarthy, CNET News.comTuesday, April 28, 2009 11:47 AM
A post on the Facebook developer blog announced the big application program interface (API) update from the social network, which it's calling the Open Stream API.
It's the first major implementation of an emerging (read: brand new) open standard called Activity Streams, on which Facebook has been collaborating with developers for the past few months.
Basically, what it means is that third-party developers will have access to a feed of all content posted to news feeds--notes, photos, videos, links, "likes" and comments, and activity from other applications built on the social network's platform.

http://www.zdnetasia.com/news/internet/0,39044908,62053619,00.htm?scid=nl_z_ntnd

Tuesday, April 28, 2009

SqlCommandBuilder Usage

SqlCommandBuilder Class
Automatically generates single-table commands that are used to reconcile changes made to a DataSet with the associated SQL Server database. This class cannot be inherited.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx

You can use the SqlCommandBuilder to update the change to the adapter generated DataSet to database, and then call the following line

adapter.Update(dataSet, tableName);

Tuesday, April 21, 2009

Export Database Table to Excel File

There are several methods to export Database Table to Excel file.
1. Export to Gridview and then to excel file

Code:
string style = @"<style> .text { mso-number-format:\@; } </style>";
GridView GridView1 = new GridView();
GridView1.RowDataBound += new GridViewRowEventHandler(gvUsers_RowDataBound);
GridView1.DataSource = [YOUR DATASOURCE];
GridView1.DataBind();
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.ContentType = "application/excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(style);
Response.Write(stringWrite.ToString());
Response.End();


protected void gvUsers_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Attributes.Add("class", "text");
e.Row.Cells[7].Attributes.Add("class", "text");
}
}

2. DataTable to Excel File:

a. Perfect solution:
//Create the DataTable first

string physicPath = HttpContext.Current.Server.MapPath("./Files");
string fileName = Guid.NewGuid() + ".Xls"

String strExcelConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=Yes'", physicPath+fileName);
DataTableToExcel(dt, strExcelConn);
Response.Clear();
Response.WriteFile(physicPath + fileName);
string httpHeader = "attachment;filename=output.xls";
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", httpHeader);
Response.Flush();


public void DataTableToExcel(DataTable dt, string connString)
{
int rows = dt.Rows.Count;
int cols = dt.Columns.Count;
StringBuilder sb = new StringBuilder();
sb.Append("CREATE TABLE ");
if (string.IsNullOrEmpty(dt.TableName)) dt.TableName = "Table1";
sb.Append(dt.TableName + " ( ");
for (int i = 0; i < cols; i++)
{
if (i < cols - 1)
sb.Append(string.Format("[{0}] varchar,", dt.Columns[i].ColumnName));
else
sb.Append(string.Format("[{0}] varchar)", dt.Columns[i].ColumnName));
}
using (OleDbConnection objConn = new OleDbConnection(connString))
{
OleDbCommand objCmd = new OleDbCommand();
objCmd.Connection = objConn;
objCmd.CommandText = sb.ToString();
objConn.Open();
objCmd.ExecuteNonQuery();
sb.Remove(0, sb.Length);
sb.Append("INSERT INTO ");
sb.Append(dt.TableName + " ( ");
for (int i = 0; i < cols; i++)
{
if (i < cols - 1)
sb.Append("[" + dt.Columns[i].ColumnName + "],");
else
sb.Append("[" + dt.Columns[i].ColumnName + "]) values (");
}
for (int i = 0; i < cols; i++)
{
if (i < cols - 1)
sb.Append("@" + dt.Columns[i].ColumnName + ",");
else
sb.Append("@" + dt.Columns[i].ColumnName + ")");
}
objCmd.CommandText = sb.ToString();
OleDbParameterCollection param = objCmd.Parameters;
for (int i = 0; i < cols; i++)
{
param.Add(new OleDbParameter("@" + dt.Columns[i].ColumnName, OleDbType.VarChar));
}
foreach (DataRow row in dt.Rows)
{
for (int i = 0; i < param.Count; i++)
{
param[i].Value = row[i];
}
objCmd.ExecuteNonQuery();
}
}
}



b. Non-perfect solution(File created does not comprise with the excel standard):
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
string sep = "";
foreach (DataColumn dc in dt.Columns)
{
Response.Write(sep + dc.ColumnName);
sep = "\t";
}
Response.Write("\n");
int i;
foreach (DataRow dr in dt.Rows)
{
sep = "";
for (i = 0; i < dt.Columns.Count; i++)
{
Response.Write(sep + dr[i].ToString());
sep = "\t";
}
Response.Write("\n");
}

Monday, April 13, 2009

Microsoft Web Platform

More than just a powerful set of tools, servers and technologies, the Microsoft Web Platform offers a complete ecosystem for building and hosting web sites, services, and applications. Whether you’re looking to build your company’s web presence or launch the next MySpace, we’ve got the products you need to be successful.

http://www.microsoft.com/web/default.aspx

Monday, April 6, 2009

Friday, April 3, 2009

Ten ways to make your boss love you - and save your job

http://news.zdnet.com/2100-9595_22-284491.html

Monday, March 30, 2009

Passing Variable To SetInterval

Today, I need to rotate the background image using javascript. I use the function setInterval to acheive this. However, I can't pass variable to setInterval as several errors occur.

Here is some websites that talking about this problem:
http://www.bigresource.com/JAVASCRIPTS-Passing-variable-to-setInterval-E2H3OB74.html#Gf8cAgFL

http://alexle.net/archives/169

PS: better use anonymous function to deal with it
For example,
setInterval(function(){alert(variable_a);}, 500);

Sunday, March 29, 2009

Internet Explorer Collection helps you test your webpages in different IEs

Each IE version in the collection has already built in the IE developer Toolbar to help developers to fix problems.

Download link:
http://finalbuilds.edskes.net/iecollection.htm

Tuesday, March 24, 2009

Cheaters turn to Web to game certification system

March 24, 2009 — Don't judge a developer by his or her certifications. Cheaters are coordinated, and the answers to exams are easily located on the Web.

Websites, including certcollection.org, examcollection.com and (until recently) sadikhov.com, host forums where members share advice, experience, and even actual word-for-word Microsoft certification test questions known in the cheating community as "MS brain dumps."

Read on:
http://www.sdtimes.com/link/33359

Server Application Unavailable

I wrote this post on my blog on how to resolve the generic Server Application Unavailable message we sometimes get as ASP.Net developers:

If you have ever received an error message on a .Net application that simply stated "Server Application Unavailable" you might find this useful.

When you receive this error, make sure to check the event viewer on the server. This is found under administrative tools. Under the application event log, you will likely find an error that states: "It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration tool to run the application in a separate process."

An application pool is a process that responds to web requests under IIS. An application pool does not have a setting for what type of ASP.Net applications will be run in it. Instead, it loads the appropriate libraries when an ASP.Net application is loaded in the process. Because the libraries for ASP.Net 1.1 and ASP.Net 2.0 are similar, but not the same, the application pool cannot respond to requests for both types of applications at the same time. This can cause sporadic behaviour if you are using the server at the same time as another developer and you have applications using different versions of the framework in the same application pool.

Make sure that on your server there is an application pool dedicated to ASP.Net 2.0 applications and one for ASP.Net 1.1 applications. When you add an ASP.Net application to the server, make sure you select the right application pool for it.

http://forums.asp.net/t/1070357.aspx

Tuesday, March 17, 2009

TryParse, TryParseExact for conversion in .net

Today, I discover a userful function called TryParse in .net programming.

Previously, if we want to convert a string to integer, we will:
Convert.ToInt32(sampleString);

However, we need to catch the Exception if the variable cannot be casted into integer. With the use of TryParse(), it will return false if the variable cannot be parsed:
int.TryParse(sampleString);

It saves some work and makes the code nicer. Also, catching exception is consuming. So TryParse() is really a good tool to use.

Saturday, March 14, 2009

Write a program in 30 minutes (for a C# programmer candidate interview question).

http://stackoverflow.com/questions/156893/write-a-program-in-30-minutes-for-a-c-programmer-candidate-interview-question#156931

JQuery: Manipulate items in dropdownlist

To select items in dropdownlist, we have several ways.

1. Select items by setting the selected value
$('#dropdown').val('option1');

2.Select items by setting the selected index
$('#dropdown').attr("selectedIndex", 3);


To add items (option) in dropdownlist:
$('#dropdown').append($('').val(val).html(html));

Check whether an item (option) is exist in the dropdownlist:
$('#dropdown option[value= yourvalue]').length > 0

Friday, March 13, 2009

JQuery Plugin: BlockUI

The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser[1]. When activated, it will prevent user activity with the page (or part of the page) until it is deactivated. BlockUI adds elements to the DOM to give it both the appearance and behavior of blocking user interaction.

http://www.malsup.com/jquery/block/

Thursday, March 12, 2009

An example of communication between JavaScript and Adobe Flash Player

Today, my project needs to send information from javascript to Flash. Read on the following article:

An example of communication between JavaScript and Adobe Flash Player


http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15683

Added: 2009-03-20

The code in the above link does not work. Some modifications are needed:

function getFlashMovie(movieName) {

if(document.embeds[movieName]) return document.embeds[movieName];
if(window.document[movieName]) return window.document[movieName];
if(window[movieName]) return window[movieName];
if(document[movieName]) return document[movieName];
return null;
}

HTTP Handlers and HTTP Modules Overview

To learn about HTTP Handlers. Read on:

http://msdn.microsoft.com/en-us/library/bb398986.aspx

How to: Register HTTP Handlers

http://msdn.microsoft.com/en-us/library/46c5ddfy.aspx


Creating an ASHX handler in ASP.NET:

http://www.aspcode.net/Creating-an-ASHX-handler-in-ASPNET.aspx

Wednesday, March 11, 2009

Add Event Listener in Javascript

Mozilla firefox Developer Center example and usage:

https://developer.mozilla.org/En/DOM/Element.addEventListener

------------------------------------------------------------------------------

Another example for this:

// Cross-browser implementation of element.addEventListener()
// Usage: addListener(window, 'load', myFunction);

function addListener(element, type, expression, bubbling){
bubbling = bubbling false;
if(window.addEventListener) { // Standard
element.addEventListener(type, expression, bubbling);
return true;
} else if(window.attachEvent) { // IE
element.attachEvent('on' + type, expression);
return true;
}
else return false;
}


http://snipplr.com/view.php?codeview&id=561

Great Posts for learning Javascript

Douglas Crockford's Blog

http://javascript.crockford.com/

What ASP.NET Developers Should Know About JavaScript

http://odetocode.com/Articles/473.aspx


Closure On JavaScript Closures

http://odetocode.com/Blogs/scott/archive/2007/07/09/11077.aspx

A Good Example:

http://stackoverflow.com/questions/643542/doesnt-javascript-support-closures-with-local-variables


Function.apply and Function.call in /javaScript

http://odetocode.com/blogs/scott/archive/2007/07/04/11067.aspx

Function.apply, Function.call and Argument list in JavaScript

I have just read about the function.apply and function.call in Scott Allen's post. It's a very useful post talking about the details of how to use it.

Do you know what the following code means?

function sample(message) {
alert(this.toString());
alert(arguments.length);
alert(arguments[0] + arguments[1]);
}

function sample2(object, func, args){
func.apply(object, args);
}

function sample3(message1, message2){
alert(this.toString() + message1 + message2);
}
var text = "Do you understand the code?";
sample.call(text, "Text 1", " and some more text");
alert("Running Sample 2");
sample2(text,sample3,[" Yes", ", I do"]);


Just read and learn:
http://odetocode.com/blogs/scott/archive/2007/07/04/11067.aspx

Multiple cookies with same name

These days I encountered a situation that I cannot set and get a cookie's value properly.

I used Fiddler tool to check about the cookie value and discover that there are two cookies with same name. I didn't realize what's the problem initially and tried to set it expire. But it still doesn't work.

Finally, after searching in Google, I realize that multiple cookies can have same name but in different path. What I need to do is to set the path when setting the cookie's value. For example,

document.cookie = "login=" + loginName + ";path=/";

If you don't set the path, you may have two cookies, one in your root directory and one in your sub-directory.

This is also a reminder for me not to have this mistake again.

Sunday, March 8, 2009

Google Webmaster Central Blog

http://googlewebmastercentral.blogspot.com/

Canonical Tag for SEO

Last week Google, Yahoo, and Microsoft announced support for a new link element to clean up duplicate urls on sites. The syntax is pretty simple: An ugly url such as http://www.example.com/page.html?sid=asdf314159265 can specify in the HEAD part of the document the following:
< link rel="canonical" href="http://example.com/page.html">
That tells search engines that the preferred location of this url (the “canonical” location, in search engine speak) is http://example.com/page.html instead of http://www.example.com/page.html?sid=asdf314159265 .

Reference:
http://www.mattcutts.com/blog/canonical-link-tag/


http://searchengineland.com/canonical-tag-16537


URL Referrer Tracking

http://janeandrobot.com/post/URL-Referrer-Tracking.aspx

Wednesday, February 25, 2009

How to make an inherited editable region uneditable

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16416

"javascript:" is replaced to "" in HyperLinkField

For security reason, ASP.net automatically replace the "javascript:" in the hyperlinkfield to empty string.

In order to run javascript function, you would better add the event by navigate DOM tree to do so.