Category Archive for 'Programming'

Constants in Objective-C

If you’re a Java programmer developing on the iPhone platform, you’ve probably wondered about how to set constants in your programs. Undoubtedly, you have have come across the #define preprocessor macro, and maybe a few other methods, but I’m going to show you my approach to this problem using the singleton design pattern.

Resetting MySQL Passwords

I downloaded a Ubuntu 8.10 VMPlanet.net image with MySQL server, but the root password was set to something other than the standard vmplanet.net password. Logging in without a password or username didn’t give me enough permissions to set my own users and change passwords. Here is the solution for this problem (thanks Keystone [...]

OS X .htaccess

For some reason, I could not get .htaccess files to work on my system for the longest time. I’ve since upgraded to Leopard, and I eventually just gave up on it (I could do that, since I’m only running a development environment).
Anyway, the solution depends on which version you’re running:
For Tiger, edit /private/etc/httpd.conf AND [...]

PHP and Internalization

I was recently tasked with supporting multiple languages in a PHP script. I found an article on about.com that was a good starting point. The author basically suggested creating associative arrays with different translations:
(P.S. I modified his code just a little to better conform to PHP 5 standards)

MySQL Triggers

I came across an interesting problem: I needed to create priorities for records in a database so that they would be able to be displayed in a particular order. Moreover, I needed to find a way to reorder the priorities on the fly. My first instinct was for each record to have its [...]

TI-85 KNN Classifier

Not really a KNN Classifier, as much as a mass, N-dimension euclidean distance calculator.
Input is a Matrix MAT of all the points to test against (row-based), and a Vector X the point to test against. Output is a Nx1 matrix V of all the distances between X and each row of the Matrix (in [...]

TI-85 Gaussian Classifier

Here’s a TI-85 program for the final that calculates the Mean Matrix, Covariances, Cv inverse, and the probability. I split it apart into two programs so that you can easily write down the answers and set your variables.
To calculate Mean, Covariance and Cv Inverse, enter the following into the program menu (I named mine GMEAN). [...]

I’m back from my surgery. Thankfully, the laptop from my new employer arrived just in time to keep me occupied during recovery. It’s a 17″ MacBook Pro with the 1920×1200 resolution screen (Sah-weet!). 4 GB of RAM. I must say, this is probably the only machine that could have EVER switched [...]

Depth-First Search in PHP

The Depth-First Search algorithm can be used to find a path between two points. I recently had to use it to draw a map in PHP. This is my implementation of a graph structure with DFS in PHP5. Download the source.