Wednesday, October 5, 2011

Free Simple Javascript Password Strength Checker

These codes came from many sources until I forgot the origins. I just combine all the good stuffs I found from the net. Sorry if I use your codes somewhere and remind me to include your credit as I forgot the origin of it.

The Javascript function:


function checkpassword(pw) {

var Score = 0;
var Result = "weak";

if (pw.length>5 && pw.length<8) { Score = (Score+6); }
else if (pw.length>7 && pw.length<16) { Score = (Score+12); }
else if (pw.length>15) { Score = (Score+18); }

if (pw.match(/[a-z]/)) { Score = (Score+1); }
if (pw.match(/[A-Z]/)) { Score = (Score+5); }
if (pw.match(/\d+/)) { Score = (Score+5); }
if (pw.match(/(.*[0-9].*[0-9].*[0-9])/)) { Score = (Score+5); }
if (pw.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) { Score = (Score+5); }
if (pw.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) { Score = (Score+5); }
if (pw.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) { Score = (Score+5); }
if (pw.match(/([a-zA-Z])/) && pw.match(/([0-9])/)) { Score = (Score+5); }
if (pw.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)) { Score = (Score+5); }


if (pw.length == 0) { Result = ""; }
else if (pw.length < 6) { Result = "too short"; }
else if (Score < 16) { Result = "very weak"; }
else if (Score > 15 && Score < 25) { Result = " weak"; }
else if (Score > 24 && Score < 35) { Result = "mediocre"; }
else if (Score > 34 && Score < 45) { Result = "strong"; }
else { Result = "strong enough"; }
document.getElementById("yourResultDivID").innerHTML = Result;
}




The HTML:

<input type=password name=pw size=35 maxlength=12 onkeyup="javascript:checkpassword(this.value);">

<div id="yourResultDivID" style="display:inline;" width=100></div>




The thing to pay attention to is highlighted in red. Something I found many other ways in the net but this is what I like.
Read More »

Wednesday, July 27, 2011

How to Set Facebook Landing Page to Your App?

Can you do this? Yes and no.

Yes, it is only applicable to those who haven't "LIKE" your page/app.

No, if your fan has already "LIKE" you. They will go to the page's wall instead.



You can refer to how to set up the app in my earlier post if you haven't made one yet. If you already have an app in place, you can easily go to your intended facebook page and then click on "Edit Page" in "Get Started" or on the wall on the top right.




You may be landed on the "Manage Permissions" link. If not, go there. Then find your app in the Default Landing Tab options. Your app should be there. After that, save your changes.

Once again, if you already "LIKE" your own, you go to WALL directly. Log out and go the facebook page, you'll be landed on the app you just picked.



Read More »

Create a Facebook iframe App/Tab (Formerly known as Fanpage Static FMBL Tab)






Many changes have been made recently by facebook and here's the official facebook tutorial on this subject:



https://developers.facebook.com/docs/beta/opengraph/tutorial/



Many steps in the following are no longer applicable.






Ever since March 11, 2011, Facebook has phased out the Static FBML support and introduced the new iframe App/Tab.

As of today 27th of July, 2011, the following steps are taken to make this work. I cannot guarantee compatibility in the future as Facebook changes its functionality very often.


Note: the FBML is no longer required. BUT you need to have your web page in HTML hosted somewhere and port it into facebook as app using the following method.


Anyway, here are the steps I found it working:



Step 1:

Go to :

http://facebook.com/developers

If you are here for the first time, you will be prompted for permission like any other Facebook apps.






Step 2:






In the developer's page, click on "Create New App" on the upper right corner. The “New App” mini window will pop out in the middle.

Then, enter App Name, Locale, and agree to the Facebook Terms. You will then be asked to complete a Captcha text recognition after that.

Note: Make sure your Facebook account is verified by mobile phone or credit card or you'll be asked to do so before proceeding further.



Step 3:

You are directed to "About - Basic Info" of this App Profile Edit control panel. Fill up the basic info such as Description, Category, Apps Icon image, Contact info, etc.

You are also given the app id and app secret here.








Step 4:

Click on “On Facebook – Canvas Settings” on the left panel as shown below.


You are then to fill up the App info such as Canvas Page, Canvas URL, Secure Canvas URL, Iframe Size, Bookmark URL, Social Discovery, Tab Name, Tab URL, etc.





The most important part is the Canvas URL which points to the URL you want it to appear in the iframe of facebook.

Remember the “http://”. The web address has to be complete. You can also include query strings in the URL but they may be treated as POST string but send with GET format. A bug that facebook has to fix someday. If you are using PERL CGI lib to capture the form data, you may need to do some tweaking.

Someone mentioned that the URL has to end with a "/". Not sure about that.

The 2nd important part is the Tab URL, it is like PATH to the Canvas URL. For root access to the web page, you may be tempted to leave it blank. But I advise you to put a “&” sign there. Leaving it blank may cause error and your app won’t show up.


Step 5:

Click on "View App Profile Page" on lower left of the facebook developers page (as shown in the image above also). You can test your settings to see if there is any error by clicking on the ”Go to App" button on top in your App Profile Page.

If it is working, you can port the app to any of your facebook page. Just click on "Add to My Page" (as shown below). Walla!









You may need to obtain permissions to your app by getting an access token. A simple click will do if you are asked to get one.



If you make a mistake somewhere, you’ll get this error which means you need to go back to http://facebook.com/developers (click on Edit below “Create New App”):


The app "xxxxxxxxxxxxxxxxxx" is temporarily unavailable due to an issue with its third-party developer. We are investigating the situation and apologize for any inconvenience.



WHERE IS THE TAB?
In fact, I have no idea. I can only see the link on the left but the Tab is nowhere to be found. Facebook may be eliminating the Tab on the wall altogether. Sorry for not being able to provide further info here.
Read More »

Wednesday, May 25, 2011

My Best Way to Place favicon.ico for All Browsers Type

Favorite Icon (favicon.ico) can help boost the professional look of your website.

But somehow different browsers support it differently. Here are the codes I use for maximum compatibility:


<head>
<link rel="icon" href="/favicon48.ico" type="image/ico"> <!-- for Mozilla based browsers -->
<meta name="msapplication-task" content="name=YOUR_ICON_NAME;action-uri=./favicon32.ico"> <!-- for IE9 -->
<link rel="SHORTCUT ICON" href="./favicon32.ico" type="image/x-icon"> <!-- for IE8 -->
</head>


Besides you also need to place a 16x16 small icon named favicon.ico in the root path of your server to be compatible with IE5/6.

Size? I would say make each of those sizes: 16x16, 24x24, 32x32, 48x48, ... just in case future IEs can use them.

What software to make them? I use Photoshop with plugin to export .ico file.
Read More »

Sunday, May 22, 2011

How to Configure Facebook Share (fb-sahre) Thumbnail & Texts?

Update on 18/12/2014: The latest version has been updated here.

This could be something a lots of new web developers wanted to know as Facebook is gaining substantial popularity each day.

If one can share its web content to Facebook, it could mean a big help to the marketing of the website.


The link you need to put the Facebook link (<fb-share>) to your website or blog:


<HEAD>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

<meta property="og:title" content="Your Title" />
<meta property="og:type" content="website" />
<meta property="og:image" content="Your Thumbnail Image Link" />
<meta property="og:url" content="Your URL" />
<meta name="description" content="Your Description" />

<HEAD>


<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>







You can also configure the font for the "Share" text.


IMPORTANT Note: If you make a mistake somewhere in your code, you need to go to Facebook URL Linter to refresh the fb-share information of your page. If not, it will be stuck at your first submission as it is cached in Facebook server for future use until you run this Linter. I also heard it will be rerun 24 hours later. I did not take this chance to wait for another 12 hours to do another round of debug. Going to this lint link should be the easiest way to debug your fb-share link:

http://developers.facebook.com/tools/lint
Read More »

Saturday, April 2, 2011

Web Browser Usage Statistic/Market Share/Popularity

Out of my curiosity, I just check the latest stat:

http://www.w3schools.com/browsers/browsers_stats.asp

To my surprise, IE is losing steam quite a lot and it is being neglected as days go by. Although Firefox is the most popular browser as of today, 2/4/11, the trend may skew towards Chrome in the near future. Good job! Google!

I expected Safari to go higher due to the popularity of iPad. But to my surprise, iPad doesn't bring much to Apple in terms of the popularity of Safari used in every iPad.

Yes, surprise, surprise and surprise.

Update (April 5th, 2016): Yes, Chrome is indeed now the winner and it is even far in the lead. Kudos! Chrome!
Read More »

Tuesday, March 22, 2011

For IE, Don't Put CSS Style inside <TABLE>

Anything CSS style setting you put inside <TABLE> will turn into something unpredictable.

Put inside <TD> instead!

For Chrome, Firefox and Safari, they are OK if you put CSS style setting you put inside <TABLE>!
Read More »

Monday, March 14, 2011

Make ASP - ADODB using MS Access MDB file to display Chinese text via UTF-8

You need this:


Response.CodePage = 65001



somewhere in your asp code. Tada!

Of course you need this in the HTML header:


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


Complete list of codepage can be found here:

http://msdn.microsoft.com/en-us/library/aa752010(v=vs.85).aspx
Read More »