Archive for August, 2006

Web Stats Notes and Thoughts

General:

Total amount of visits to the website is good information, but we need to dig into the hits deeper to understand more. This information is stored in log files on the machine. However, it isn’t in a presentable manner. Thus, a GUI for web statistics.

Breaking down the total hits in such categories as; Overall, Monthly, Daily, Hourly is good to get a bigger picture about who’s coming too your website.

Where are your visitors coming from? Are they mostly from the US? Primarly the US and the UK? This is also
information that can be displayed.

You can also find which search queries they used to find your site, what page it presented them with. Who’s referring too your site.

I think one of the biggest values of web statistics is too see if money spent on advertising is working.

Are people linking to pages that don’t exist? We can fix this so people visit our site.

Mac OS X RAID Notes

Trying to get a Macintosh to boot off a RAID Array

I’m trying to use Apple’s built-in raid and it is surprisingly difficult! Sure, I am trying to do this on the boot disk, but that shouldn’t be a big deal, it can be done in linux.

First I tried creating a striped raid to boot off of. No go. At first, it woulnd’t let me. Then somehow I tricked it into letting me, and then when I rebooted the dreaded you must reboot your computer screen showed up. Back to the drawing board.

Now I am trying to create two partitions on each disk, where I will create one mirrored partition as the boot disk, and the striped partition as the local storage unit. Right now I’m waiting for the raid to rebuild. I can’t cancel it though, if I could I would so I could just start over. Ugh.

This guy is having the same problem as I:
http://www.askbjoernhansen.com/2006/03/30/only_one_apple_raid_partition_1.html#comments

"Waiting for new RAID to come online"

It pisses me off when software like this is released! With some better documentation, things would be fine. Looks like I found the documentation. They say:

"In server versions verions 10.1 to 10.1.4 and client verions 10.1 to 10.2.8, RAID volumes can be used as data volumes only - not as the startup disk on which system software is installed. You can RAID a startup volume in 10.3 or later."
and
"Disk Utility used with Mac OS X offers RAID levels 0 and 1. A RAID set of two or more hard disks may be level 0 or 1, but not both, when set up with Disk Utility. Third-party products may offer different levels of RAID."

While I’m not sure about the first one, it definitely wasn’t booting off a striped raid. The second one I can confirm right away. So I’m booting off a regular drive partition, 10GB, with a 277GB striped array, and 10GB of free, unused space. I journaled the boot drive for reliability, and did not journal the raid for added performance.

Alas, when I rebooted, the computer again asked me to restart, saying it had failed miserably. Here Apple says you can create RAID arrays from startup volumes as long as you boot from another disk:

http://docs.info.apple.com/article.html?path=DiskUtility/10.5/en/duh1013.html

Apple has misrepresented the functionality of their software, bigtime.

New strategy
I have deleted my RAID array, and am simply installing the OS to the 10GB partition. Once it has installed and I can confirm it will boot, I will upgrade the OS. After that, I will again reboot of the install DVD and run Disk Utility to create the RAID AGAIN! If this doesn’t work I’m going to cry.

  • That didn’t work.

Another new strategy
Remembering that I recently sped up my linux raid by removing jumpers to enable 3.0GB/s sata II speeds, I added a jumper to the samsung drive I just bought. See Disk Drive Notes for more info.

That still didn’t work, so now I’m trying again with no raid present, installing the OS on the old drive. Maybe then I restart successfully? Next I will have to remove the new disk and try simply with the old. One other idea, I sincerely hope this doesn’t have anything to do with the old mac_fdisk partitions I made with Gentoo’s PPC installer. I can check that too. I’ve got time.

The SOLUTION:

HAHA. Tried to unplug the other disk, still kernel panic. Now I’ve removed the random nic card I plugged in there earlier this week. Maybe that will do it? Holy cow it was indeed the networking card. I take back all the nasty things I said about Apple. No wonder, it was throwing a kernel panic at the registration screen, where Apple tries to "phone home" and tell them your secrets.

Sweet! I just rebooted with my fresh new striped array. Awesome!

To boot into a striped array, you have to use partitions in your array, rather than actual disks. Apple must put some information on the smaller hidden parts of the physical device that tell the boot process about the paritions, and thus the raid. Cool! If you create a raid with just physical device disks, you will not be able to install the os.

Related:
Disk Drive Notes

PHP Lesson 4 - Database




PHP has a lot of database functions, which greatly contributed to its popularity. The goal of this lesson is to see how this can work for a simple example. To do so, we will need to complete the following steps:

  1. Connect to a database - hopefully you have a mysql database running already, and you know a user and password to use. Use mysql_connect() function for this.
  2. Query the database, asking it for some information you would like to get. Use mysql_query function for this.
  3. One the database has given you the information, you’re not quite ready yet. You will need to access the object and format the rows to a more normalized method. You can use the mysql_fetch_row function to do so.

PHP Lesson 5 Control Structures

Control structures give you the ability to do more sophisticated tasks with your scripts. Say for example you have an Excel spreadsheet with a list of addresses in CSV format, and you wanted to enter the information into a database. You could do it manually (quite a laborious, inefficient, and expensive task), or you could have PHP do it for you. How can you get PHP to loop through all the information? You can use one of the following control structures:

  • foreach
  • for
  • while

Say you wanted to skip addresses that aren’t located in the United States. How can you get PHP to differentiate between the data? Using conditionals of course! The following terms represent some conditional statements in PHP:

  • if
  • else
  • elseif
  • case
  • switch

With conditionals, you need to use operators to test your conditions. Here are some examples:

  • == the two items are equal
  • != the two items are not equal

As well as:

  • && and
  • || or

A conditional mostly tests for truth. For example, the following code is asking whether what is between the parentheses is true:

<span style="color: #000000">
<span style="color: #0000BB">&lt;?php

</span><span style="color: #007700">if(</span><span style="color: #0000BB">5</span><span style="color: #007700">==</span><span style="color: #0000BB">2</span><span style="color: #007700">) {
 </span><span style="color: #FF8000">// then...
</span><span style="color: #007700">}

</span><span style="color: #0000BB">?&gt;</span>
</span>

In this case the condition is not true, so PHP will not execute what is between the curly brackets. Along these lines, you can use functions that return a boolean value of true of false. For example, the function:

<span style="color: #000000">
<span style="color: #0000BB">&lt;?php

</span><span style="color: #007700">isset()
</span><span style="color: #0000BB">?&gt;</span>
</span>

returns a true/false value depending on whether a variable is set.

PHP Tasks:

  1. Please write some code using the above concepts to loop 10 times and pring "Hello world!" to a browser window.
  2. Once you have successfully completed task 1, add an if statement within the loop to skip loop number 7.
  3. Post your completed and working code to this page.

PHP Resources:
http://devzone.zend.com/node/view/id/628

http://www.quepublishing.com/articles/article.asp?p=381922&rl=1

http://www.developer.com/lang/php/article.php/947911