Debugging Dojo on IE


This took me a few days to figure out so I thought I'd share it...

I had written some code and everything worked fine in Firefox but in IE7 and IE8 I got a JavaScript error:

loader.js: "Could not load 'dojox.gfx'; last tried '../dojox/gfx.js'"

Like a good debugger, I had set isDebug:true in my djConfig but unfortunately neither the IE JavaScript error message nor the IE Developer Tools (Shift+F12 in IE8) told me much. I Google'd the problem and discovered this was a generic error that could be the result of a lot of different problems. Great...just what I needed...

I spent days debugging loader.js using JSLint, changing baseUrl, altering IE security settings, troubleshooting my Apache configuration, altering my VirtualBox get the idea. Finally, I stumbled across bug fix #5398 that mentioned debugAtAllCosts. Hmmm...that's interesting. I wonder what that does? I replaced isDebug:true with debugAtAllCosts:true and voila!, the IE JavaScript error now magically pointed to vml.js, not loader.js, allowing me to track down the problem: a missing semi-colon in my code! (arrrgghhhh....)

So, bottom line, use debugAtAllCosts in djConfig instead of isDebug!

P.S. Another issue that catches me every now and then is page caching. In IE, make sure to go to Tools > Internet Options > General (tab) > Browsing History (section) > Settings (button) and select the Every time I visit the webpage radio button.

Driver issues when installing VirtualBox on Ubuntu 10.04


Installing VirtualBox, I got this error: Kernel driver not installed '/etc/init.d/vboxdrv setup'


1. Run command: sudo apt-get install linux-headers-$(uname -r)-preempt
2. Run command: sudo apt-get install dkms
3. Run command: sudo apt-get install virtualbox-ose
4. Run command: sudo /etc/init.d/vboxdrv setup

P.S. If you'd like the VM OS to access the Internet and also computers on the local network (such as a web server running on the Host) use "Bridged Adapter" for the Network type:

Install Cheesecake Photoblog on Ubuntu 10.04


Cheesecake Photoblog is a nice photo gallery for CakePHP. To install on Ubuntu, follow these steps:

1. Install LAMP

2. Install FireBug

3. Install FirePHP (Note: 1.0 release will be called FireConsole)

4. Download Cheesecake Photoblog 2.0

5. Download CakePHP 1.2.7 (Note: As of this writing, Cheesecake Photoblog is not compatible with CakePHP 1.3)

6. Run command: sudo chown -R your_Ubuntu_username /var/www

7. Open cheesecake_cake.tar.gz and extract the index.php and .htaccess files as well as the app and vendors folders into /var/www

8. Open the CakePHP 1.2.7 zip file and extract the cake folder into /var/www

9. Run command: sudo chmod -R 777 /var/www/app/tmp

10. Run command: sudo chmod 777 /var/www/app/config

11. Run command: sudo chmod 777 /var/www/app/webroot/img/photos

12. Install GD: sudo apt-get install php5-gd

13. Enable Apache mod_rewrite: sudo a2enmod rewrite

14. Run command: sudo gedit /var/www/app/config/core.php

15. In that document, find the Security.salt entry on line 153 and change the strrev value to a random alphanumeric string that's at least as long as the default one. Once you change the value, save and close the file.

16. Run command: sudo gedit /etc/apache2/sites-enabled/000-default

17. In that document, change the DocumentRoot /var/www line to be DocumentRoot /var/www/app/webroot

18. Change

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

19. Save and close the 000-default file

20. Run command: sudo service apache2 restart

21. Create the Cheesecake Photoblog MySQL database: mysql -u root -p -e "create database cheesecake2; grant all on cheesecake2.* to 'your_desired_username' identified by 'your_desired_password';"

22. Open Firefox and go to: http://localhost/admin/install

23. Follow instructions to configure Cheesecake Photoblog

24. When prompted to change permissions of the config directory, run command: sudo chmod 755 /var/www/app/config

25. When you click the Continue button you should see the Home page of Cheesecake Photoblog!

Note: You will also see the SQL query of each page request shown at the bottom of each page. To turn this off, open /var/www/app/config/core.php and change debug level to 0 or 1 (default level is 2).

Annoying Dojo 1.5 syntax error


When running Dojo 1.5 locally on a brand new project, bootstrap.js threw 11 errors in Firebug:

SyntaxError: syntax error
(601 out of range 505)

It turns out some Dojo components are looking for internationalization js files in folders called en and en-us instead of the root of their nls folders (where the files exist).

To fix these errors, you need to create the en and/or en-us folder and copy the referenced js file from the parent folder into them. For example, in the screenshot above I had to create a folder called en-us in my DOJO_ROOT/dijit/form/nls folder and copy the DOJO_ROOT/dijit/form/nls/validate.js file into it: DOJO_ROOT/dijit/form/nls/en-us/validate.js

I had to repeat the process for all 11 missing js folders/files. Annoying, but I hope the workaround helps someone else having the same issue.

Installing MongoDB 1.6 on Ubuntu 10.04 and PHP 5


These steps should help you quickly install the latest stable version of MongoDB on Ubuntu and PHP:

* Note: this guide assumes you already have LAMP installed and functional.

1. Run command: sudo gedit /etc/apt/sources.list

2. Paste this at bottom of file: deb 10.4 10gen

3. Run command: sudo apt-key adv --keyserver --recv 7F0CEB10

4. Run command: sudo mkdir -p /data/db/

5. Run command: sudo chown `id -u` /data/db
* Note: that's a ` (keyboard key to left of the 1 key) not a ' (keyboard key to left of Enter key)

6. Run command: sudo apt-get update
* Note: for some reason the first update didn't work so I had to run the command a second time

7. Run command: sudo apt-get install mongodb-stable

8. Wait for the installation to finish. To test installation was successful, run command: mongo

You should now be connected to test (if not, run command: sudo service mongodb restart)

Type help for a list of options

Run command:{test:1});

Now we have a new collection named myTestCollection. It has one document in it called test, which is expressed as an object with one attribute (1):
test: 1

Run command:{test:2});

Now our test document has two attributes:
test: 1
test: 2

You can see these values by running this command: db.myTestCollection.find();   This will return all documents within the myTestCollection collection:
{ "_id" : ObjectId("4c5b8ebd13ba33c8ab9d0052"), "test" : 1 }
{ "_id" : ObjectId("4c5b8f7a13ba33c8ab9d0053"), "test" : 2 }

* Note: Mongo requires an unique ObjectId '_id' value for each attribute and will auto-create it for you if not provided (easiest and recommended).

If you want a specific attribute, you can identify it in the query. For example: db.myTestCollection.find({test:1});
{ "_id" : ObjectId("4c5b8ebd13ba33c8ab9d0052"), "test" : 1 }

I know... I know... The query syntax is a little weird at first because it's JavaScript-based and will probably seem foreign to traditional relational database admins. A nice comparison between familiar SQL and Mongo commands can be found here. Perhaps someone will eventually create a JavaScript library to convert traditional SQL queries into Mongo-style queries.

Type exit to quit the mongo console.

Now that MongoDB is functional, you need to configure PHP to use it:

9. Run command: sudo apt-get install php-pear

10. Run command: sudo apt-get install php5-dev

11. Run command: sudo pecl install mongo

12. Run command: sudo gedit /etc/php.ini

13. At bottom of the php.ini file (or first line if file is empty), add this line:

14. Restart your web server for the change to take effect (e.g. sudo service apache2 restart)

15. You can now start using MongoDB with PHP!

P.S. An important security discussion can be found here.

Install Apache, PHP, MySQL, and CakePHP on Ubuntu 10.04 (newbie install)


If you want to install Apache, PHP, and MySQL on Ubuntu 10.04, do the following:

1. Run command: sudo tasksel install lamp-server

2. Follow prompts to install Apache, MySQL, and PHP (this is often referred to as 'LAMP' where L stands for Linux)

Congratulations, you've successfully set up LAMP!