Sunday 29 March 2009

Code Igniter can't Find a Function

PHP Logo
While working my way thru Professional Code Igniter I ran into this error:


Fatal error: Call to undefined function base_url() in /Users/mw119255/si/ci/book/system/application/views/template.php on line 6


Turns out I forgot to enter the suggested helpers and libraries into autoload.php as listed on page 56 of the book. At the moment I haven't loaded the database library. That will happen after I get the basic UI going and then start working on the functions that rely on the db. The book puts in calls to methods that haven't been written yet as you build the UI. As I prefer a more incremental approach with a working application, I am putting in comments in for those calls. The code is uncommented as each method is built.




Wednesday 25 March 2009

Free Clip Art?

Need some free clip art for your site royalty free and without strings? Check out http://openclipart.org. They seem to be the most legit site out there. All the licenses for the art are clearly listed and explained. No pop-ups, pop-unders or other bovine feces.

Tuesday 24 March 2009

A Small Rant on Slide Deck Training

I think I have ranted on this before, but it merits a second round. A Power Point presentation does not constitute training!!!! In addition, Power Point sucks as a medium for tutorials and how to's.


In my experience, 9 out of 10 times, a stand up Power Point information blast is the wrong option. It doesn't scale well and no one will remember what you said the next day. You are much better off writing a tutorial, a how to, or making a screen cast. Any of these options provides more information to your target audience and will be much more helpful in the long run.

Monday 23 March 2009

Featured gadget: Economic Forecast Meter



Name: Economic Forecast Meter
Author: The Idea Support Laboratory Hirameki Juku
Description: The sun shows next boom! When the number of sunspots increases, the economy gets powerful. This gadget shows the number of sunspots to predict the next boom.

More information | Download gadget

Each week this blog features a recently added Google Desktop gadget that looks promising. If you'd like to see all new Desktop gadgets as they're published, subscribe to the RSS feed.

Friday 20 March 2009

Update to Adsense Privacy Policy

Google is going roll out a new type of cookie for Adsense. If you are an Adsense user you need to update, your privacy policy. To check out the details check out this link.

Friday 13 March 2009

And Now With Multi-language Support!

Read an article today on how to make your site appeal to international audiences on Problogger. So this got me hunting around to see if there was some tool I could easily include on my web page to do this.


I found this page on Yahoo's Bablefish site. Just choose the widget, cut and paste the code, and voila! Instant translator on any web page. Very cool. Check it out on the right side of this page.

Tuesday 10 March 2009

jQuery UI

Ran across this post on Ajaxian. Looking for widgets to work with jQuery, check out the http://jqueryui.com/ site.


I have not had a chance to check this out, but it looks very promising.

Saturday 7 March 2009

NetNewsWire for iPhone


In an effort to expand the amount of information I can read on my iPhone, I decided to investigate RSS readers for the iPhone. What gave me the push to do this was the limited number of iPhone friendly websites there are on the net. All the major news sites have iPhone friendly pages (FoxNews, CNN, NY Times, BBC). But that is really about it. And even on the 3G network, loading pages can be kinda slow.


A number of options were tried before NetNewsWire for the iPhone. The Google Reader has an iPhone interface, but is sucks. Safari has an RSS reader build it, but it isn't any better then the Google reader. Since I used to use NetNewsWire on my Mac before I switched to online readers and it is a wonderful application. The application has been bought by NewsGator, so information about NetNewsWire for the iPhone can be found here. Turns out the iPhone version is free and can be downloaded from the iTunes store.


The application is great. It has a very nice tabbed interface much like the UI for the iPod application. Each feed has a nice finger sized line for each feed title. When you click on the title, you get a nice list of story headers. Click on the header and you get the feed summary for that entry. The feed is rendered in a very readable manner, often much better than it would look on the web page. In addition, if the web site includes the full entry text in the feed, you can read the whole post right there in the reader. I should also mention that if only a link is included, NetNewsWire renders the page inside the reader. This seems to work pretty good. You can also choose to render the page in Safari if you wish.


You manage the feeds from the NewsGator web site. You have to register an account, but once you do, you can manager your feeds here. Once you add a few feeds, click the refresh button on the front page of NetNewsWire and magically, all your feed data is downloaded and available.


If you have a iPhone, check it out. Highly recommended.

Wednesday 4 March 2009

MySQL 101 on OS X - Part II

MySQL Logo

The database is up and running and you have a user account. Now you need to create a database and load it with data. Since I am working on the Professional CodeIgniter book, I will use the database for that book as an example. You can download the claudias_kids.sql file from here. This file will be used to create a claudias_kids database.



Creating the Database


Creating the database is really straight forward. Just use the SQL create database command.


mysql -u monty -psomePass -v -e "create database claudias_kids;"

That is it. Your database has been created.



Loading Data


The next step is to load the database with tables and data. Often when working with a book example, the code to create the test tables and data is provided for you. The data is generally stored in a "dump" file, named after the utility used to export data to a file. A dump file is used in this example. The syntax for loading the data for the claudias_kids database is:


mysql -u student -psomePass claudias_kids < claudias_kids.sql

This command executes all the SQL code in the claudias_kids.sql file. Your database should now be full of tables and data.


To get list of tables, type:


"mysql -u student -psomePass -e "use claudias_kids; show tables;"

To list the contents of the products table, try this:


mysql -u student -psomePass -e "use claudias_kids; select * from products;"

Backing Up the Database


Now you have installed your database. What if you want to back it up after making changes to it? A backup can be created using the mysqldump utility. For example, to backup the claudias_kids database you would use this command.


mysqldump -u root -psomePass --databases claudias_kids > claudias_kids_bk.sql

The command creates a dump file just like the one you used to install the database. The command can be run at any time to save any changes you make to the database.


Well that concludes the posting on MySQL for now. Hopefully that gets MySQL up and going so you can get focused on coding.

Tuesday 3 March 2009

MySQL 101 on OS X - Part I

MySQL Logo

Well, to get started with my CodeIgniter book, I needed to get MySQL setup again on my machine. So for my own future reference, here are the steps to do that.


Install MySQL


This is pretty easy, go to mysql.com and download the open source server for your operating system. I used the version 5.1.31 for Mac OS X 10.5. There is lots of info on the MySQL site for this if you need it.



Starting and Stopping the Server


The first step is to start the server. On OS X, MySQL is located in the /usr/local/mysql/bin directory. You may want to put this directory in your path to save keystrokes.


To start the MySQL server use this command as root:


sudo bash

/usr/local/mysql/bin/mysqld_safe &

This should get the database server up and running in the background. To test the server to see if it is running, run the mysql client.


mysql

If the server is running you should see something like this:



macpro:~ # mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.31 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

If the server is not running, you will get an error message like this:



ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Eventually, you will want to stop the server. That it done with the following command (also as root):


/usr/local/mysql/bin/mysqladmin shutdown

You can start and stop the server, now it is time to setup a development account.



Creating a User Account


You can actually do all your development using the default root account with no password set. But this is a bad idea. Once you move your code to a hosted web server, you will need to use a username and password to use MySQL. So you might as well get used to it now.


The command to add a user to MySQL is straightforward, but a bit verbose. Here is an example:


mysql


GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' IDENTIFIED BY 'somePass' WITH GRANT OPTION;


quit

First your start the client and enter an SQL statement. The SQL command creates a superuser account (all privileges are granted) for a user named "monty" connecting from the server named localhost, with a password of 'somePass'. Type quit to exit out of the client.



Alternate Ways of Entering MySQL Commands


Using the text interface of the MySQL client is only one way to enter SQL statement and commands into MySQL. I find the text client to be a bit clunky, so I often enter SQL statements on the command line like this:


mysql -u monty -psomePass -v -e "mysql statement;"

This command executes the SQL statement from the command line and displays the output there. The -v option provides verbose output. The -e option defines the SQL statement to be executed. The advantage of this sort of setup is you don't have to leave you shell prompt to perform database functions. In addition, it is easy to script the command line option. For example, a simple shell script for executing commands might look like this:



#!/bin/bash
mysql -u monty -psomePass -v -e "$1"

Or, if I wanted to script the add user functionality in say Perl, it might look something like this:


   1:#!/usr/bin/perl -w
2:
3:my $userToAdd = "monty";
4:my $userPassword = "somePass";
5:my $hostName = "localhost";
6:
7:# SQL String
8:my $sqlStr = "GRANT ALL PRIVILEGES ON " . '*.*' . " TO '$userToAdd'\@'$hostName' IDENTIFIED BY '$userPassword' WITH GRANT OPTION\n";
9:
10:#print $sqlStr;
11:system "mysql -u root -p -v -e \"$sqlStr\" ";
12:
13:

For someone like me who makes a lot of typo mistakes, this is really helpful.


Well that ends part I. In part II, I will create a database and load a dump file into the database.


For more information see:


Monday 2 March 2009

Savings Accounts

This is a little off topic, but worth posting anyway. In these difficult financial times, you want to make sure you park your cash in a safe place and still earn a good rate. I found savingsaccount.com which lists the best rates of return on FDIC insured savings accounts. Definitely worth a look if you bank is only paying 1 percent or less.

Wierd Style Errors with Dojo

Dojo Logo

This problem has bitten me in the rear end one too many times, so I thought I had better write something. Whenever you run into a weird formatting problem with a page using Dojo. Whevever all the class definitions look right, all the includes look right, everything looks right, and the formatting still is not right. Check the <body> tag.


<body class="tundra">

Nine of ten times, you have not set the class equal to "tundra". I keep doing this and it drives me nuts. lol. Always check the obvious first.

Sunday 1 March 2009

CocoaMySQL Moved to Sequel Pro

The CocoaMySQL tool for MySQL on Mac OS X has be renamed to Sequel Pro and moved to a Google code site. A nice simple little tool for MySQL on your Mac.

Professional CodeIgniter Source Code


You can get the source code for the book here. A must have as I am not sure every step in building the application is covered.


I will try to fill in some blanks as I run across them.