[Solution] How to use this in setInterval and setTimeout problems inside objects

| No Comments »

Problem: One of the problems we find when using setInterval and setTimeout functions in javascript is how the special variable this is switched to the window object on the instance the function executes inside the interval.

Answer: Store the current object in a variable (for this example, the variable is called self) and use that variable for your interval’s function instead of this.

function foo()
this.init = function () {
var self = this;
this.interval = setInterval(function(){ self.update(); }, 1000); // this can be setTimeout

this.update = function () {

Json Example

Solution for Headers Already Sent problem in php scripts and frameworks

| No Comments »

Headers already sent issue?

Here’s how to fix one of the most common problems in frameworks and websites:

Problem: Help! i’m getting the errors and/or warnings – “Headers already sent!

Answer #1: Check the php files which are usually found in your headers(the ones which are loaded first, typically config.php) and look for extra spaces before your <?php start tag and spaces after ?> end tag. Delete them and voila! Problem Solved!

Answer #2: Check your header scripts(The first few lines of code) and make sure you’re not outputting anything(e.g: an echo, sprintf or a warning message) before using header.

Ultimate guide to installing Windows 7 64-Bit(x64) in your Macbook White and solutions to Bootcamp driver problems!


Problem #1: Help Me! How do I install Windows 7 in my macbook while retaining Mac OSX.

Problem #2: Driver issues! I can’t install my 64 bit bootcamp drivers in Windows 7!

Problem #3: Sound: My Macbook sounds very tinny and awful in Windows 7

Problem #4: Right Clicking: How do I right click in Windows 7 using macbook?

Problem #5: How do I disable my trackpad if my mouse is present in Windows 7?

Problem #6: How do I rebind some of my macbook keys in Windows 7?

_Introduction_: This guide will help you install Windows 7 to your Macbook and also solve the Mac driver issues in Windows 7. Although the case sounds like Bootcamp Drivers doesn’t support Windows 7 64 bit on some macs(Core 2 duo), this is not exactly true as you can still install the 64 bit drivers(Scroll down to the “Windows 64-bit drivers installation” section to see more details). Another solution is to use a virtual machine like VMWare Fusion and Parallels. They basically put Windows and OSX side-by-side and it works wonderfully (Great for web developers and those who want to have that coolness factor added to OSX)

How To Install Windows 7 while retaining your current OSX Installation:

Step 1. Start OSX (Leopard / Snow Leopard), Run Bootcamp Migration Assistant (type “bootcamp” in your finder)

Step 2. During the Bootcamp Migration Wizard, create a partition with around 30gb+ of disk space. After completing the wizard, OSX will prompt you to restart with the Windows 7 CD in your drive.

If OSX is complaining about being unable to continue with bootcamp, you probably need to defrag your Macintosh Drive. To do this, download a defragger software such as “iDefrag” and do a complete defrag on your primary hard disk, unfortunately you can’t really do a complete defrag on the hard disk you are currently running OSX in so you will need an external hard disk to boot from in order to do this. Please see step 1 of “How to backup your OSX and do a Fresh Install of Windows 7 and Leopard / Snow Leopard in your Macbook” below to find out how to run OSX from an external hard disk. Once you’re running OSX in your external drive, run “iDefrag” and defrag your primary hard-drive. Once defragged, restart macbook and you should be able to complete Bootcamp now.

Step 3. After restarting, you’ll be greeted by the Windows 7 setup, complete each steps until Windows 7 asks you where to install it, simply select the drive that is labeled: “BootCamp” and format it(it is disabled until you format it, don’t worry it’s safe.).

Step 4. Congratulations! Windows 7 has been installed, now insert your Leopard / Snow Leopard Installation Disk and Navigate to your CD Drive Folder —> Boot Camp —> Drivers —> Apple and open “BootCamp64”. If an alert window is informing you that your current OS is not supported, don’t worry as it’s easy to fix that. Please scroll down until you get to the Windows 7 64 bit Driver Installation for Macbook section.

How to backup your OSX and do a Fresh Install of Windows 7 and Leopard / Snow Leopard in your Macbook:

Step 1: Backup your system to an external hard disk: Connect an external hard disk to your macbook and run this awesome software called SuperDuper to backup your files. Once backed up restart your macbook and hold Alt/Option until your see a boot selection menu, select the external hard disk with the backup you made in SuperDuper, if all goes well you should be running OSX, only this time, you’re running it in your external hard-drive(your backup). If you are comfortable with how the backup looks, proceed with the following steps:

Step 2. Run Disk Utility (type “disk” in finder to see it from the list of Applications)

Step 3. Format your Macbook’s Hard-drive(Take care that you don’t select the external one.).

Step 4. Insert your Leopard / Snow Leopard Installation CD, while restarting hold ALT/Option to get to the boot menu. Select your Leopard / Snow Leopard CD and complete your OSX installation.

Step 5. After Installation, boot your newly installed OSX and run Bootcamp Migration Assistant (type “bootcamp” in your finder), complete the Bootcamp Migration Wizard and insert your Windows 7 CD before proceeding to restart:

Step 6. After restarting, proceed to install your Windows 7, when Windows 7 ask you where to install it, simply select the drive that is labeled: “BootCamp” and press the format button(don’t worry it’s safe).

Step 7. Congratulations! Windows 7 has been installed, now insert your Leopard / Snow Leopard Installation Disk and Navigate to your CD Drive —> Boot Camp —> Drivers —> Apple and open “BootCamp64”. If an alert window is informing you that your current OS is not supported, don’t worry as it’s easy to fix that in the next section.

Installing your macbook’s Windows 7 64 Bit Drivers. Important: The following is only required if you can’t install the 64bit drivers that’s included in your Leopard/Snow Leopard Installation Disk.

Step 1. In Windows, press Start —> Select “Run” — Type “Cmd”, from the Programs List, right click on “cmd.exe” and select “Run as Administrator”

Step 2. In Windows Command Prompt, enter the following command: net user administrator /active:yes

Step 3. Press Start —> Logout and re-login, select the “Administrator” Account from the selection.

Step 4. Navigate to your Leopard CD Drive Folder —> Boot Camp —> Drivers —> Apple and open “BootCamp64”, complete the installation and you’re all set!

Step 5. Remove the administrator account from showing up by going to Start —> Run —> Cmd —> press enter. Type the following command from the command prompt: net user administrator /active:no

After the installation of these drivers, you may notice your macbook sounding really tinny or pitchy, this is easily fixed by installing the sound driver from Realtek.

Step 6. Download Realtek HD Audio Drivers here.

Step 7. That’s it! Perhaps the final step is to tweak your keyboard/trackpad settings by accessing the Bootcamp Control Panel (This can be seen in your system tray — lower right portion of your task bar, click the arrow besides the date if you can’t see it. If you still can’t see it, simply press Start and type “boot camp” to find it.)

To right click in Windows 7 using your trackpad, touch your trackpad with 2 fingers and click on the button. If you are like me, you may prefer to do a 2 finger tap to do a right click, you can do this by going to Boot Camp Control Panel(Press start and type “Boot Camp” to find it), go to the trackpad tab and click on One Finger Tap to Click and secondary click below Two Fingers.
There’s a nice software called Trackpad Magic, it’s a very handy tool that allows you to disable your trackpad easily via the system tray. It also have a nifty option that automatically disables your trackpad when a mouse is present/plugged in. For the best effect, add a shortcut of the Trackpad Magic program to your startup folder.
If you are uncomfortable with how some of your keyboard keys are setup, you may want to rebind them using the Remapkey software. Remapkey is included with the Windows Server 2003 Resource Kit Tools. You can find it in the c:\Program Files\Windows Resource Kits\Tools directory called remapkey.exe respectively.

Well, that should cover it! Don’t forget to share this in stumbleupon to help those who are looking for a similar solution.

How to: Fix OCUpload/One-Click Upload clicking bug in IE7 & IE8 (jquery)

| 1 Comment »

Problem: Help! I’m using the OCUpload, or One Click Upload Plugin for Jquery. IE7 and IE8 is requiring me to do a double click to display the upload dialog box!

Solution: The one-click upload technique uses a trick that sets the file input’s browse button directly in front of your mouse cursor. This is misbehaving in IE7/IE8 due to how they handle CSS, this can be resolved by directly setting the cursor position through javascript instead. You can fix the problem by editting the script and updating the following lines (highlighted in bold):

Somewhere on line 87:

/** Move the input with the mouse to make sure it get clicked! */ container.mousemove(function(e){    input.css({        top: e.pageY-container.offset().top+’px’,        left: e.pageX-container.offset().left-175+’px’    }); });

Finally, we need to set the margin css property to 0, you can find it somewhere on line 63:

/** File Input */ var input = $(        ‘<input ‘+        ‘name=”‘+options.name+'” ‘+        ‘type=”file” ‘+        ‘hidefocus=”true” ‘+      ‘/>’ ).css({      background: ‘#ffffff’,      position: ‘relative’,      display: ‘block’,      marginLeft: 0+’px’,      opacity: 0 });

That’s it! Hope this helped!

How to: Fix Adium can’t connect to Yahoo Messenger


Help: Adium can’t connect or is unable to connect to Yahoo! even after restarting the application or the whole OS.

__UPDATE__(6/24/09), Important!

Adium’s latest update includes a fix for this bug so please do download the update and after installation please make sure your connection’s login server is back to the default: scs.msg.yahoo.com, and ports: 5050, that should fix it.

Here’s a quick fix to this problem

  1. Disconnect(or Cancel) if your account is currently connecting.
  2. Change your connection’s login server from scs.msg.yahoo.com to, leave port 5050 unchanged. (You can do this by going to File -> (Select your Yahoo! Account) -> Edit Account, you can also do this in the File -> Preferences -> Accounts -> Edit
  3. Try Connecting Again.

That’s It! The steps above should be done to _each_ of your yahoo accounts.

__UPDATE__: This solution works for Pidgin as well so you may want to share this with your pidgin buddies who are experiencing the same problem.

Ciick here to share this solution with others who are experiencing the same problem!



Problem: So I’ve decided to turn off compression(My Computer -> Select a Drive -> Right Click “Properties”) to speed up my computer. Compression saves disk space but it seems to slow down my computer whenever it’s accessing massive amount of files.

I was prompted to restart my PC so I did, I was then greeted by an error that says:


Press Ctrl+Alt+Delete to Restart


There are 4 (possible) fix for this problem.

Option #1: Boot from your Windows Vista DVD and select Repair your Computer -> Startup Repair.
Option #2: Boot from your Windows Vista DVD and select Repair your Computer -> Command Prompt, execute the following commands: bootrec /fixboot bootrec /fixmbr Reboot.
Option #3: At the prompt to select your OS installation, click the button that says ‘Load Drivers’. This should bring up a explorer-style drive browser.Then just right-click on the drive you tried to compress, and deselect ‘Compress this Drive’, which should still be ticked on. Hit apply, and apply to subfolders/files. Reboot.
Option #4: Boot from your Windows Vista DVD and select Repair your Computer -> Command Prompt, in the command prompt, execute the following commands by typing them and pressing enter for each line: c: expand bootmgr temp attrib bootmgr -s -r -h del bootmgr ren temp bootmgr attrib bootmgr -a +s +r +h Reboot.(If the 2nd line fail, go back to 1st line and replace C with the drive letter of where your windows is installed.) -OR- execute the following where C is where your windows is installed: (thank you Liviu from Neosmart.net for sending this in) compact /U C:\bootmgr compact /U C:\ntldr

That’s it! Hope that helped you out.

How to fix: WordPress Admin keeps on Auto Refreshing

| No Comments »
I have this annoying problem with my wordpress admin when adding or editting a new post, it just keeps on refreshing!

After a few search, i’ve stumbled upon this post. It seems that the problem occurs when you have firebug or the gears plugin enabled. After disabling it, im still getting the same results so i’ve tried restarting Firefox instead and bingo! it works. From the looks of things, the problem occurs when you have a Firefox update pending so restarting your browser is the simple fix.