Archive for the 'Uncategorized' Category

Microsft SharedView

Saturday, March 29th, 2008

This is not a Microsoft bashing blog, so when the folks from Redmond put out something good we are all over it. If you haven’t had a chance to use Microsoft SharedView, you might want to try it out. It is a free application but it is still in beta. Recently I have been working on a project where I need to collaborate with a buddy of mine in San Diego. We have been using SharedView to work together on his Vista PC, but I was unable to share my XP box with him. My screen would be gray instead of showing my desktop. Turns out the problem has to do with my Nvidia video card and hardware acceleration. Here is how to fix the problem:
Click on Start menu > Control Panel > Display > Settings > Advanced > Troubleshoot > Move the slider to "None" to disable hardware acceleration

Create a new MySQL database from the command line

Friday, March 28th, 2008

Set a root password if none exists
$ mysqladmin -u root password <new_password>

Login to MySQL
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16 to server version: 5.0.22-Debian_0ubuntu6.06-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON databasename.* TO “username”@”hostname” IDENTIFIED BY “password”;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> EXIT
Bye

XHTML Validation Tip

Thursday, March 27th, 2008

Just a tip to all you aspiring web designers, please use lower case when creating web pages. I just had to clean up a bunch of HTML with a mix of UPPER and lower case tag names and it was not fun. The World Wide Web Consortium (W3C) had to say on the matter:

Element and attribute names must be in lower case
XHTML documents must use lower case for all HTML element and attribute names. This difference is necessary because XML is case-sensitive e.g. <li> and <LI> are different tags.

If you are unsure about your code, test it using these websites and save your fellow developers from having to clean up your mess:

HTML Validator: http://validator.w3.org
CSS Validator: http://jigsaw.w3.org/css-validator

Bluetooth file transfer on Ubuntu

Wednesday, March 26th, 2008

Configuration
sudo apt-get install obexftp obexpushd gnome-bluetooth bluez-utils
sudo pico /etc/bluetooth/hcid.conf
change passkey from the default “1234″ to your own passkey
sudo pico /etc/rc.local
Add the following on the line before “exit 0″
hciconfig hci0 inqmode 0
Restart the system

Sending Files from an Ubuntu PC to Another Device
The easiest way to send files from your PC to a Bluetooth device is to create a desktop shortcut onto which you can drag and drop files. Follow these steps to create the shortcut:

  • Right-click the desktop, and click Create Launcher.
  • In the Name field, type something like “Send file via Bluetooth”.
  • In the Command field, type “gnome-obex-send”.
  • You can also choose to give the new shortcut an appropriate icon. Click the No Icon button, and then type the following into the Path field: /usr/share/icons/gnome/48×48/stock/io/stock_bluetooth.png
  • Click OK.

After you’ve created the icon, you can send files as follows:

  • Drag and drop a file onto the launcher (icon) you just created.
  • The Choose Bluetooth Device dialog box appears. Click Refresh to make the computer detect any nearby Bluetooth devices. This may take a minute or two. Remember that your device will need to be set to be “visible,” so that other Bluetooth devices can automatically detect it.
  • Select the device to which you want to transfer the file, and then click OK.
  • Check the device to see if the file transfer needs to be authorized. If the devices are paired, the transfer might take place automatically.

Connecting to an Oracle 8 database using PHP4 is not for mere mortals

Monday, March 24th, 2008

Connecting to an Oracle 8 database using PHP4 is no simple task. Before calling me a moron for not using the most recent versions of these applications, you should know that I was attempting to create a mock production environment so I could deploy this solution on an existing server. Using a virtual machine to test stuff like this would be a wise thing to do since you can roll the entire system back if you mess up, just a tip.

What you need:

  • A crusty, old Oracle 8 database server (might also work with 8.x)
  • An equally crusty, old version of ApacheFriends XAMPP 1.4.4
  • A slightly less crusty, but almost as old Oracle 9i Database Release 2 Client
  • Strongly Recommended - A fresh Windows XP virtual machine (VM)

Honestly, it isn’t really that hard once you know which version of the Oracle client to use. Here is a rundown of each Oracle Client:

  • Oracle 8 - PHP complains
  • Oracle 9 - The only one that none of the components bitch about
  • Oracle 10 - Oracle complains
  • Oracle 11 - Oracle complains

Now for the steps:

  • Fire up your Windows XP VM (Be sure to use “Bridged”, not “NAT” if you are using VMWare)
  • Install XAMPP
  • Install Oracle 9i R2 Client using the default install location settings (Be sure to select the “Runtime” installation type). I canceled the “Oracle Net Configuration Assistant” because I am not set up for that.
  • Reboot the computer to make sure the PHP _SERVER["Path"] and _ENV["Path"] variables get updated.
  • Create a tnsnames.ora file in the folder “C:\oracle\ora92\network\ADMIN” and include an entry for the server you want to access. Obviously, modify the information below to match your connection settings, here is an example: db=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=PROTOCOL=TCP)(Host=hostname)(Port=1521)))(CONNECT_DATA=(SID=db)))
  • Open the Command Prompt and type: “tnsping db” If you cannot use the tnsping command, make sure your Oracle 9 installation is listed at the beginning of the “Path” variable for Windows (Contol Panel > System > Environment Variables). Ensure you have something like “C:\oracle\ora92\bin”. Don’t proceed until tnsping returns something to the effect of “Blah Blah…OK (10 msec)”. If you get “TNS-03505: Failed to resolve name”, check your tnsnames.ora file for errors.
  • Now you need to edit the php.ini file. Make sure the line starting with extension_dir has the correct path to your extension directory. For example: extension_dir = C:\xampp\php\extensions\
  • Also in the php.ini file,uncomment the line “extension=php_oci8.dll” (delete the semi-colon) to activate the Oracle extension in PHP. You might have multiple php.ini files on your system, just make sure you update all of them.
  • Start the Apache web server. If you get errors on start up, you might have missed a step.
  • Use the phpinfo link on your local ApacheFriends start page or create a phpinfo() script of your own to display the current php configuration. If Oracle is enabled you should see a section like this:
    oci8
    OCI8 Support enabled
    Revision $Revision: 1.183.2.12 $
  • The very last trick is that you have to use the deprecated php4 oci commands rather than the shiny new php5 ones. From what I have seen so far oci* commands work, oci_* commands aren’t compatible with php4.

Try running this first to make sure everything is working:

<?php
$conn = OCILogon("username", "password", "db");
if ($conn){
print "Connection Established. ";
}
OCILogoff($conn);
print "Connection Closed.";
?>

Here is a fancier example which outputs the results of a select statement into an html table:

<?php
$conn = OCILogon("username", "password", "db");
$sql = "<PUT A SELECT STATEMENT IN HERE>";
$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
$rows = OCIFetchstatement($stmt,$results);
$keys = array_keys($results);
$table = "<table>\n <TR>\n";
foreach($keys as $key)
{
$table .= " <TH>$key</TH>\n";
}
$table .= " </TR>\n";
for($i=0;$i<$rows;$i++)
{
$table .= " <TR>";
foreach($results as $spalte)
{
$data = $spalte[$i];
$table .= ” <TD>$data</TD>”;
}
$table .=” </TR>”;
}
echo $table;
OCILogoff($conn);
?>