Kamis, 24 Februari 2011

How To Install Internet Explorer 6 so You Can Test Your Website On IE6

Q: I am running a website on my local machine and I'd like to validate it on Internet Explorer 6 but I am not able to install IE6 on my Windows. What can I do?
If you've read Guide on Cross Browser Compatibility you'd know the importance of testing IE6 as it accounts for a significant percentage of website traffic. If you have trouble installing IE6 on your Windows OS follow the following steps:

* Go through Install IE6 on Windows: Although this guide talks about installing IE6 on Windows 7 it should apply to other Windows OS as well. Install a virtual PC with Windows XP on it so you can run IE6 in that Windows XP. After you install it run the Windows XP profile.

* Access your local machine through internal IP: Find out your internal IP through 'ipconfig' via command line in your local machine (NOT virtual PC!). It should be something like 192.168.xxx.xxx. Then make sure your web server allows a client to access it via this IP. This depends on the web server you use. If you use Apache make sure you have the following in your httpd.conf (assuming "C:\repository\trunk-php" is your document root):

<Directory "C:\repository\trunk-php">
Allow from all
</Directory>

instead of the default configuration

<Directory "C:\repository\trunk-php">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
</Directory>

Now open an IE6 browser in your virtual PC and go to http://192.168.0.56 or whatever your local IP is!


Now you should be able test your website on Internet Explorer 6! Any question let me know!

HTML <img> Tag Issue In Google Chrome

Q: Why can I not get correct width and height of an image via Javascript in Chrome?On my other website Men's Fashion For Less I use a lot of jQuery plugins. I used http://www.smoothdivscroll.com/ to auto scroll a bunch of photos and to my surprise Chrome is not handling the scrolling image functionality correctly. Later I finally found out why. Read on to learn how I solved it.

AnswerIf you use jQuery a lot in a website and are currently trying to validate your website in Chrome, you may be surprised that it's not handling images the same way Internet Explorer and Firefox are via javascript. Basically if you are trying to get the width or height of an image via javascript or jQuery like the following:

var img = document.getElementById('imageid');
//or however you get a handle to the IMG
var width = img.clientWidth;
var height = img.clientHeight;


you need to make sure either of the following:

* The <img> tag has width and height specified as attributes or via CSS, or if you prefer...

* Use

$(window).load(function() {...})

instead of

$(document).ready(function() {...})

So that the Chrome can successfully detect the width and height of an image once it's loaded.


This is due to the fact that Chrome is a Webkit browser (same issue applies to Safari) and for some reason you need to explicitly tell Chrome the height and width of an image if you want to be able to access them via javascript. Internet Explorer and Firefox are able to detect the dimension of an image without you having to do the above. I am not sure why. Anyone care to enlighten me?

Senin, 07 Februari 2011

Solve PHP "Failed To Open Stream: No such file or directory in Unknown on line 0" Error

Question
I am running WAMP on Windows 7 and my WAMP directory is at C:\wamp. I specify 'C:\wamp\www' to be my document root in Apache's httpd.conf. I create a symbolic link, C:\wamp\www\myWebSite, to point to a directory, D:\myWebSite, where my website content is located. I got the following error in the browser when trying to access any of my web pages under D:\myWebSite:

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required 'C:/wamp/www/index.php' (include_path='.;C:\php5\pear') in Unknown on line 0

I've looked at the logs but there's nothing helpful. Can anyone help?

Answer
This error occurs because the latest WAMP uses PHP 5.3 which does NOT support directory junction (soft link) or hard links in Windows (refer to How To Create A Soft Link In Windows for a tutorial on creating a soft or hard link in Windows). Questions? Given this situation you have at least the following two solutions:

Solution #1: Use an older version of PHP like 5.2I tried version 5.2.11 and soft links work fine. This means rolling back PHP module to 5.2. You may have to edit the path of the following line in httpd.conf:

LoadModule php5_module "c:/wamp/bin/php/php5.3.0/php5apache2_2.dll"
And you may have to do download other related modules as well. Of course you can try to find an older WAMP that uses PHP 5.2. In my opinion this is not a good solution as you need to pull many changes once you install WAMP, which goes against the purpose of using WAMP.

Solution #2: Use correct DocumentRootIn your Apache's httpd.conf change DocumentRoot to the actual website folder which in this case is D:\myWebSite, and change other related settings accordingly. Delete the soft link C:\wamp\www\myWebSite. This should be a much better solution as your website content can be located anywhere in your file system.

Any questions let me know!

How To Create A Soft Link In Windows

I ran into the situation where I needed to create a soft link (also known as symbolic link) on Windows 7, but after some searching on the web it turns out not to be a straightforward task. In Unix you simply do 'ln -s '. In Windows there are two ways of doing it:

1. Open a command prompt window and use mklink command. If you want to soft link to a directory you execute:

mklink /j C:\soft\link\name C:\path\to\target\directory
or
mklink /d C:\soft\link\name C:\path\to\target\directory

Note: The difference between /j and /d is /j creates a symbolic link while /d creates a hard link. Since you are linking to a directory you won't see any difference at all. Using the link created either way you'll be able to navigate to the destination folder and see its contents with no differences.

If you get an error saying you need admin privilege simply run the command prompt as the administrator as shown below:

How To Run Window

If you want to create a soft link to a file you do:

mklink C:\soft\link\name C:\path\to\target\file

2. Right click drag a target file from a Windows explorer window (namely a folder) to another explorer window and release. Then pick 'create a shortcut here' to create a shortcut. Then you simply double click on the shortcut icon to go the target. However if you open a command prompt window and try to navigate to the target via the shortcut through 'cd' you'll see an error. This makes this method useless in most situations.

Any question let me know!

Kamis, 03 Februari 2011

Create An SVN Project On An SVN Server

Q: I am using Eclipse on Windows and I'd like to check out SVN project with Eclipse. How the hell do I do it?

MenuCheck Out SVN In Eclipse On Windows
Create An SVN Project On An SVN Server
Download And Install TortoiseSVN
Check Out SVN Project Via TortoiseSVN
Validate SVN Integration With Eclipse

You use 'svnadmin' command to create an SVN repository where you will put in SVN projects. If you don't know how to do it google 'svnadmin create'. Let's assume your (intended) SVN server is running on Linux and you'd like the repository to be /home/michaelwen/svn. Subversion uses this directory to store information about your projects such as file revisions. You won't need to directly deal with this directory; so let's keep it in a safe place and not mess with its contents unless you know what you are doing. The command is the following:

svnadmin create /home/michaelwen/svn

Let's create a directory in your SVN repository to store a project named 'myproj':

svn mkdir file:///home/michaelwen/svn/myproj

Now go to the local folder where you keep the source code you'd like stored in the repository and add an SVN project via the 'svn import' command. An example is the following:

cd /home/michaelwen/where-my-code-for-myproj-is/myproj
svn import file:///home/michaelwen/svn/myproj -m "first import of myproj"


This command will put all contents in /home/michaelwen/where-my-code-for-myproj-is/myproj in file:///home/michaelwen/svn/myproj recursively.

◀ Check Out SVN In Eclipse On WindowsDownload And Install Tortoisesvn ▶

Validate Svn Integration With Eclipse

Q: I am using Eclipse on Windows and I'd like to check out SVN project with Eclipse. How the hell do I do it?

MenuCheck Out SVN In Eclipse On Windows
Create An SVN Project On An SVN Server
Download And Install TortoiseSVN
Check Out SVN Project Via TortoiseSVN
Validate SVN Integration With Eclipse
As I mentioned earlier you may not need TortoiseSVN at all if your Eclipse works fine with SVN. Read on to make sure this is the case. Even if this is not the case we've got a fall back solution for you.

To use SVN with Eclipse simply download and install Subclipse. Refer to any web tutorial on this topic if you haven't done so. Now when you use Subclipse to check out code from your SVN repository you may get the following error dialog:

Eclipse Subclipse SVN Operation Failure Dialog

If you do don't panic. This dialog is saying Subclipse fails to create ssh tunnel. A quick solution is simply change SVN interface from 'JavaHL (JNI)' to 'SVNKit (Pure Java) SVNKit' in Window -> Preferences -> Team -> SVN -> SVN Interface as follows:

Eclipse Subclipse SVN Interface Dialog

Once you made the change you should be able to use SVN operations smoothly within Eclipse! If you still don't for some reason, and I've heard cases like that, fall back on using TortoiseSVN to manage SVN checking out, updating, and committing changes to your code in Windows Explorer and use Eclipse to edit your code! It'll still be efficient once you get the hang of it.

◀ Check Out SVN Project Via TortoiseSVN

Check Out SVN Project Via TortoiseSVN

Q: I am using Eclipse on Windows and I'd like to check out SVN project with Eclipse. How the hell do I do it?

MenuCheck Out SVN In Eclipse On Windows
Create An SVN Project On An SVN Server
Download And Install TortoiseSVN
Check Out SVN Project Via TortoiseSVN
Validate SVN Integration With Eclipse
Once you have TortoiseSVN installed you can easily check out an SVN project into any local directory you want. Let's say you'd like to download some project into your D:. Right click on D: in any Windows Explorer window and pick 'SVN Checkout...' as follows:

TortoiseSVN SVN Checkout

xxx.xxx.xxx.xxx is the IP address where I hosted my project at. You should use your own SVN URL.

Click OK and you should see the checkout in progress like the following:

TortoiseSVN Svn Checkout In Progress

Once it says checkout done you are done! Now check your D: and the project should be checked out at D:\repository.

◀ Download And Install TortoiseSVNValidate SVN Integration With Eclipse ▶

Download And Install TortoiseSVN

Q: I am using Eclipse on Windows and I'd like to check out SVN project with Eclipse. How the hell do I do it?

MenuCheck Out SVN In Eclipse On Windows
Create An SVN Project On An SVN Server
Download And Install TortoiseSVN
Check Out SVN Project Via TortoiseSVN
Validate SVN Integration With Eclipse
TortoiseSVN is one of the most common Subversion clients you can find that runs on Windows OS. Once you install it you'll be able to see SVN operation options in the context menu (the menu that shows up when you right-click your mouse) and be able to perform any of those options. Technically you will NOT need TortoiseSVN once you get Eclipse integrated with Subversion on Windows but TortoiseSVN still provides great utility to you. If you don't feel like using it feel free to move on.

Instructions
Simply go to the download site of TortoiseSVN and download and install it. Note that you must download the version that matches your OS architecture (either 32-bit or 64-bit). If not you will NOT see the TortoiseSVN options in the context menu when you right-click some directory like it says you would:

TortoiseSVN Download 32 Bit Versus 64 Bit

After installing and rebooting you'll be able to see the following SVN operation options in the context-menu just like the following:

TortoiseSVN Context Menu

◀ Create An SVN Project On An SVN ServerCheck Out SVN Project Via TortoiseSVN ▶

Check Out Svn In Eclipse On Windows

Q: I am using Eclipse on Windows and I'd like to check out SVN project with Eclipse. How the hell do I do it?

MenuCheck Out SVN In Eclipse On Windows
Create An SVN Project On An SVN Server
Download And Install TortoiseSVN
Check Out SVN Project Via TortoiseSVN
Validate SVN Integration With Eclipse
Not sure where to start but I've had an amazingly difficult time to do this task. I am running Eclipse on Windows and I have my Subversion (SVN will be used in short from this point on) project running in some remote server. All I want to do is check out that SVN project and be able to integrate it with Eclipse so that I can do SVN operations within Eclipse instead of do them via command line. The problem is that the web server I am running on that remote server is Nginx, which does NOT have a standard way of integrating with SVN yet like Apache does. Therefore all I have is svn+ssh protocol to manage my SVN project, but the Subclipse plug-in for Eclipse seems to ONLY accept HTTP protocol as the SVN URL. Later I found out once I change the SVN interface it all works fine (described at Validate SVN Integration With Eclipse).

Can I blame it on Nginx? Can I blame it on Eclipse? Anyway finally I managed to solve this issue in the following steps. Preconditions are that I am running Windows 7.

1. Create an SVN project on your SVN server

2. Download and install TortoiseSVN: You may not need TortoiseSVN if your Eclipse is integrated with Subversion successfully but it's still a great tool to have.

3. Check out your SVN project through TortoiseSVN: Again you may not need TortoiseSVN if your Eclipse is integrated with Subversion successfully but in case it doesn't you have TortoiseSVN to fall back on.

4. Validate SVN Integration With Eclipse


Let's get started on how I managed to handle this monstrous issue!

Create An Svn Project On An SVN Server ▶
 
support by: infomediaku.com