Thursday, December 31, 2009
Facebook connect in Facebook Developer toolkit
http://www.rjygraham.com/archive/2009/11/22/using-facebook-connect-with-aspnet-mvc-and-the-facebook-developer-toolkit-3.aspx
http://blogs.claritycon.com/blogs/kevin_marshall/archive/2009/10/06/facebook-developer-toolkit-3-0-asp-net-mvc-sample.aspx
Facebook developer toolkit v2
http://devtacular.com/articles/bkonrad/how-to-retrieve-user-data-from-facebook-connect-in-aspnet/
Wednesday, December 30, 2009
Monday, December 28, 2009
Thursday, December 3, 2009
Wednesday, December 2, 2009
Tuesday, December 1, 2009
Singleton pattern
http://en.wikipedia.org/wiki/Singleton_pattern
Saturday, November 28, 2009
Remove null element in PHP array and reorder
$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
Thursday, November 26, 2009
Wednesday, November 25, 2009
Inversion of control
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?
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.
Monday, November 23, 2009
Wednesday, November 18, 2009
Database Connection Pool
http://en.wikipedia.org/wiki/Connection_pool
http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx
Factory Method Pattern
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 17, 2009
Sunday, November 15, 2009
Wednesday, November 11, 2009
Tuesday, November 10, 2009
IE6 png fix
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
Saturday, November 7, 2009
Thursday, November 5, 2009
Reading a file content
StreamReader sr = new StreamReader(Server.MapPath("xxx.txt"));
string m_sOutput = sr.ReadToEnd();
Facebook Application Box Development
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
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
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
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;
}
Wednesday, October 28, 2009
Cannot find System.Globalization.CultureAndRegionInfoBuilder??
Thursday, October 22, 2009
Flash cannot read a plain text file directly
The file content has to be:
1. variable format
value=32
2. xml format
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="s" style="background-color: green; width: 350px; height: 300px;">
</div>
<script><br />if (f.scrollWidth > f.clientWidth){<br />alert("overflowed");<br />}<br /></script></div>
Tuesday, October 20, 2009
Monday, October 19, 2009
Get user list of facebook application
You have to store it in your own database.
Thursday, October 15, 2009
Facebook API call usage
IList
FQL equivalent:
public static T Deserialize
{
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
litTest.Text = photos.Count.ToString();
lvPhotos.DataSource = photos;
lvPhotos.DataBind();
}
Steps for using XFBML
Using XFBML for prompt permission
Constraint: The action needs to be initiated by user
To do it automatically, using JS API instead.
Wednesday, October 14, 2009
Facebook Authorizing Applications
Using Facebook Developer Toolkit CanvasIFrameBasePage
The allow access popup will appear automatically.
IFrame vs FBML Facebook pages
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個資料結構的模型,
讓我們可以參考,
其中排行前二十名的如下
- Libraries and Books
- Inventory Control for Retail Stores
- Hotel Reservations
- Video Rentals
- School Management
- Clients and Fees
- CD Collections
- Customers and Invoices
- Payroll
- Apartment Rentals
- Customers and Services
- ERP
- Car Sales
- Customers and Addresses
- Driving Schools
- Health and Fitness Clubs
- Hospital Admissions
- Inventory of Files in Boxes
- Sports Clubs
- 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:
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");}
Tuesday, October 13, 2009
Facebook Tutorial in ASP.net
http://fbtutorial.qsh.eu/
This tutorial makes use of the Facebook developer Toolkit.
Another tutorial (Chinese version):
http://6yeah-facebook.blogspot.com/
Monday, October 12, 2009
Sunday, October 11, 2009
Fixing the IE Overflow Vertical Scrollbar Bug
http://www.ookii.org/post/the_joys_of_overflowauto_and_crossbrowser_development.aspx
I come up with this solution:
#divInfo {float:left; width:400px; overflow-x:auto; overflow-y:hidden;padding-bottom:20px;}
Friday, October 9, 2009
Apache PDFBox - PDF version 1.5
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
Tuesday, October 6, 2009
Rsync for Windows
http://stackoverflow.com/questions/106544/rsync-on-windows-socket-operation-on-non-socket
http://en.wikipedia.org/wiki/Rsync
http://en.wikipedia.org/wiki/Delta_encoding
SyncToy
http://www.microsoft.com/downloads/details.aspx?familyid=c26efa36-98e0-4ee9-a7c5-98d0592d8c52&displaylang=en
http://www.mydigitallife.info/2008/01/01/schedule-synctoy-to-run-and-automatically-and-repetitively/
http://www.terinea.co.uk/blog/2007/10/15/backup-tools-mirror-backups-and-microsoft-synctoy/
Sunday, September 27, 2009
Thursday, September 24, 2009
OledbException: " Data type mismatch in criteria expression"
Try to avoid this if possible.
Wednesday, September 23, 2009
Office Open XML examples
http://social.msdn.microsoft.com/Forums/en-US/oxmlsdk/thread/b88e07f6-c146-4990-8f61-c73ceafa186d
MSDN How do I
http://msdn.microsoft.com/en-us/library/cc850837%28office.14%29.aspx
Open XML format resources center
http://msdn.microsoft.com/en-us/office/bb265236.aspx
Creating pivot table in excel 2007
http://msdn.microsoft.com/en-us/library/dd891207.aspx
Office Developer Community Submitted Content
http://msdn.microsoft.com/en-us/office/cc441428.aspx
SMS length problem
Sunday, September 20, 2009
Build iphone app with C# using monotouch
http://www.youtube.com/watch?v=M0VoyhKFmWg
Speed up your javascript Tutorial
http://www.youtube.com/watch?v=mHtdZgou0qU&feature=channel_page
Great Tutorial!
Friday, September 18, 2009
Thursday, September 17, 2009
jQuery UI datepicker js error: length is null or not an object
http://code.google.com/p/jquery-datepicker/issues/detail?id=56
http://dev.jqueryui.com/ticket/4071
Wednesday, September 16, 2009
Tuesday, September 15, 2009
Monday, September 14, 2009
Select 30% of records randomly in SQL Server
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
this.Page.ClientScript.RegisterClientScriptBlock
Wednesday, September 9, 2009
Is the Internet Killing Critical Thinking?
Tuesday, September 8, 2009
Sunday, September 6, 2009
Sunday, August 30, 2009
Sort JSON by its key(properites)
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
XSS (Cross Site Scripting) Cheat Sheet
http://amix.dk/blog/viewEntry/19432
Thursday, August 27, 2009
Wednesday, August 26, 2009
Send email to a folder instead of SMTP server when testing
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\Temp\" />
</smtp>
</mailSettings>
</system.net>
Tuesday, August 25, 2009
Sunday, August 23, 2009
Friday, August 21, 2009
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 "";
}
Wednesday, August 19, 2009
Get url without filename
Tuesday, August 18, 2009
Thursday, August 13, 2009
Javascript date validation
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
The possible cause:
1. The file is already there and cannot be overwritten even the permission is set.
IIncorrect MIME Type for CSS Files
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
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
Thursday, August 6, 2009
Wednesday, August 5, 2009
Discussion on changing chode that written by other colleagues
http://stackoverflow.com/questions/206286/how-do-you-tell-someone-theyre-writing-bad-code
Download the Builder.com Ten Commandments of Egoless Programming
http://articles.techrepublic.com.com/5100-10878_11-1045782.html
Tuesday, August 4, 2009
IIS Web Deployment Tool
Web Deployment Project
http://weblogs.asp.net/scottgu/archive/2008/01/28/vs-2008-web-deployment-project-support-released.aspx
http://blogs.msdn.com/webdevtools/archive/2008/01/25/announcing-rtw-of-visual-studio-2008-web-deployment-projects-wdp.aspx
Monday, August 3, 2009
Linq to SQL DataContext Lifetime Management
http://blogs.msdn.com/dinesh.kulkarni/archive/2008/04/27/lifetime-of-a-linq-to-sql-datacontext.aspx
http://stackoverflow.com/questions/337763/linq-to-sql-multiple-single-dbml-per-project
http://stackoverflow.com/questions/1949/are-multiple-datacontext-classes-ever-appropriate
http://stackoverflow.com/questions/1127283/linqtosql-mapping-out-the-datacontext-with-lots-of-tables
Sunday, August 2, 2009
Saturday, August 1, 2009
Thursday, July 30, 2009
Create and Traverse XML using LINQ to XML
http://msdn.microsoft.com/en-us/library/system.xml.linq.aspx
http://weblogs.asp.net/scottgu/archive/2007/08/07/using-linq-to-xml-and-how-to-build-a-custom-rss-feed-reader-with-it.aspx
http://wiki.asp.net/page.aspx/84/linq-to-xml/
Wednesday, July 29, 2009
Open XML format SDK
http://msdn.microsoft.com/en-us/library/bb448854%28office.14%29.aspx
Blog series:
http://blogs.msdn.com/brian_jones/archive/2008/10/06/open-xml-format-sdk-2-0.aspx
http://blogs.msdn.com/brian_jones/archive/2008/10/14/open-xml-sdk-2-0-architecture.aspx
Download Link:
http://www.microsoft.com/downloads/details.aspx?familyid=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en
IIS becomes unresponsive
http://stackoverflow.com/questions/1199246/asp-net-application-becomes-unresponsive
Tuesday, July 28, 2009
Monday, July 27, 2009
10 skills developers will need in the next five years
A few measures that speed up your 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
Thursday, July 16, 2009
Wednesday, July 15, 2009
Monday, July 6, 2009
Materials for Comet
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
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
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
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
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 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?
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
Monday, June 29, 2009
Friday, June 26, 2009
Graded Browser Support
http://developer.yahoo.com/yui/articles/gbs/
The IE6 equation
http://24ways.org/2008/the-ie6-equation
Thursday, June 25, 2009
10 UI Design Patterns You Should Be Paying Attention To
ASP.net DataContractJsonSerializer
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
Tuesday, June 23, 2009
Monday, June 22, 2009
Import 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".
Thursday, June 18, 2009
Javascript/jQuery Tutorial
http://net.tutsplus.com/tutorials/javascript-ajax/24-javascript-best-practices-for-beginners/
DataTables - Table Plugin for jQuery
http://www.datatables.net/
Monday, June 15, 2009
Thursday, June 11, 2009
Tuesday, June 9, 2009
Monday, June 8, 2009
Google Earth - Shelter Competition
Thursday, June 4, 2009
Monday, June 1, 2009
Diaster Recovery Planning
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
2. Run the initialize method as the window.onload function.
Thursday, May 28, 2009
setting of htaccess
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
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
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
Wednesday, May 20, 2009
First-time project managers need failures
http://www.zdnetasia.com/techguide/techmanagement/0,39044902,62054210,00.htm?scid=nl_z_tgtm
Friday, May 15, 2009
KeyWord Research Tools
SEO for Firefox
http://tools.seobook.com/firefox/seo-for-firefox.html
Rank Checker
http://tools.seobook.com/firefox/rank-checker/
Reference:
Thursday, May 14, 2009
Database Publishing Tools
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
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>
<asp:requiredfieldvalidator id="rfvExample" runat="server" initialvalue="0" controltovalidate="ddlExample" text="select plz">
</asp:requiredfieldvalidator>
Sunday, May 10, 2009
6 Words That Make Your Resume Suck
http://www.squawkfox.com/2008/11/17/10-things-that-define-a-killer-resume/
Interview and Job Search
The interview question you must be ready for
http://www.codeproject.com/News.aspx?nwid=8535
The Power of Persuasion in a Job Search
http://www.cio.com/article/print/479135
Saturday, May 2, 2009
XSS (Cross Site Scripting) Prevention Cheat Sheet
Wednesday, April 29, 2009
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
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);
Friday, April 24, 2009
Tuesday, April 21, 2009
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");
}
Saturday, April 18, 2009
Templated ASP.NET User Controls
How to: Create Templated ASP.NET User Controls
http://msdn.microsoft.com/en-us/library/36574bf6(VS.80).aspx
ITemplate Interface
http://msdn.microsoft.com/en-us/library/system.web.ui.itemplate.aspxhttp://msdn.microsoft.com/en-us/library/system.web.ui.itemplate.instantiatein.aspx
Monday, April 13, 2009
Microsoft Web Platform
http://www.microsoft.com/web/default.aspx
Monday, April 6, 2009
Use JSON.net to manipulate object
To serialize and deserialize JSON object.
I use the following library:
JSON.net 3.0:
http://james.newtonking.com/archive/2008/08/25/json-net-3-0-released.aspx
P.S.
In ASP.net 3.5, we can also use the following class:
system.web.script.serialization.javascriptserializer
PS2:
A new class called DataContractJsonSerializer can be used.
Friday, April 3, 2009
Ten ways to make your boss love you - and save your job
Tuesday, March 31, 2009
Monday, March 30, 2009
Passing Variable To SetInterval
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
Download link:
http://finalbuilds.edskes.net/iecollection.htm
Friday, March 27, 2009
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
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
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
JQuery: Manipulate items in dropdownlist
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
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;
}
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
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
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
Canonical Tag for SEO
< 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
Sunday, March 1, 2009
Wednesday, February 25, 2009
"javascript:" is replaced to "" in HyperLinkField
In order to run javascript function, you would better add the event by navigate DOM tree to do so.