Friday, April 30, 2010

C++ - Eclipse

Links: Short tutorial   C++ examples   Connecting C++ to MySQL   makefile tutorial   make manual  

Test-driving the Eclipse Java/C++ interface (IDE) as part of my continuing work on the Paperhater database solution. Previously, I thought a LAMP was the best idea, but the four layers of software make it challenging to focus on function. I intend to do a LAMP version as I gain PHP ability, but a C++ application needs to be accomplished to get basic functionality. One hitch...I don't know any C++.

Make (gcc)
Although this post is mostly about the Eclipse IDE, I will likely eventually rely on hand-made Makefiles for more fine-grained control. As an example, Paperhater needs to interface with MySQL. There are special compilation commands to allow code to interface with MySQL. These are unlikely to be managed by a generic IDE, unless it allows for customization.

This interface is a great thing. It's oriented around Java, but I don't want to write in Java until they solve the problems they seem to have with JRE in Linux environments. The C++ IDE (Eclipse calls it "CDT" C++ Development Tool) can be downloaded directly into Eclipse. This is just a plug-in for Eclipse, since Eclipse was designed for Java programming. But it's nearly as robust as the Java tool.

The CDT is Eclipse version specific. When I went to the CDT download page, it noted I would need the link specifically for my Eclipse release. I have Eclipse "Ganymeade" (aka version 3.4.1). I copied the link they provided for version 3.4.1,, to my clipboard.

With the link in my clipboard, I went to Eclipse and: Help->>Software Updates->>Available Updates. Select "New Sites" and put the link in there. Eclipse downloaded and configured the necessary CDT files once I pointed it to that link.

Sunday, April 25, 2010

Yellow Dog - 2002 eMac Pt 1

Links: the eMac   eject the cd tray   eMac disassembly

A friend recently graced me with a CRT display 2002 eMac (apparently built 07/11/2002). The system would not boot as of late. These early eMacs are underpowered dinosaurs with 128MB of RAM, a 700 MHz processor, and so on, although they were the thing to have in 2002. To make it available for classroom use, a free OS, a keyboard, a mouse, and a GB of RAM seemed right, hopefully while remaining beneath $100.

some features
Model A1002 G4 700 MHZ Power PC
Firmware 4.x OS
Display 17" CD-R/W
NVIDIA graphics(32MB VRAM)
Upon disassembly, I learned I had also lucked into the prior owner's decision for a 512MB RAM upgrade, giving a total of ~641MB RAM. Taken with a 700MHz processor speed, watching video might or might not be possible.

Yellow Dog
To get it running, Yellow Dog linux looked like a natural choice. They've apparently released a PPC distro (in this case 6.1 dated 20081119) for some time. The originally installed software was Mac OSX 10.1.4, and it supposedly could handle up to 10.4.11. If any of these became available later, I could always blow-out the Yellow Dog.

For hardware upgrades, it looked like I could get a $50 keyboard, a $60 RAM upgrade to 1GB, upgrade the 2x speed "Super Drive" (optical drive) to a 32x DVD-RW, and put in a larger IDE HDD than the standard 60 GB, if I wanted. But a keyboard and mouse at least.

CD/DVD tray
In order to install Yellow Dog, I had to open the CD/DVD tray. The CD/DVD drive tray flap on the front of the shell would not open with the system powered-off. Powered-on, the system was not booting, so I could not use the keyboard eject. So, it was a Catch-22. Luckily, the shell needed to be removed anyway to clean 8 years of dust from the system.

I found, upon disassembly, that the flap opens from the top to the bottom, that is, the hinges are on the bottom of the flap covering the DVD drive. Unpowered, one can insert a small screwdriver at the top of the flap and pull the flap down. Additionally, the Airport card is behind a cover plate, behind that flap. To change the Airport card then, open the flap and remove the interior cover plate (two Phillips). Pulling the Airport card should be accomplished before the disassembly required for swapping the DVD drive or the HDD.

Disassembly was no problem; essentially, a 2.5 mm hex and a good Phillips. I followed these instructions and would only add one clarification; The power switch cable needs to be disconnected from the chassis, not from the cover, this was left unstated in the guide. Needle nosed pliers were helpful to apply removal pulling pressure on the plug itself rather than pulling on the plug's (thin) wires. The plug is keyed for proper reinstallation. Disassembly voids the warranty, apparently, but that was no problem on a donated system.

Once apart, as expected, the insides were caked with dust. Dust is a large problem for enclosed cooling systems that rely on unfiltered air (think also "laptop"). I took an air hose to the uncovered chassis before proceeding further.

As I got into the system, it appeared that a RAM upgrade had already taken place. It appeared to be a 512MB card, which would provide 756MB RAM, probably enough. At any rate, adding or deleting RAM involves nothing more than removing the bottom plate. The same for changing the jumper on the optical drive, albeit the angle is slightly difficult. I moved the jumper from the far left (slave) to the center jumper, hoping this was the right setting for "master". This is needed so I can boot off the DVD. We'll see if I got it right -- there was no jumper sticker.

Sunday, April 11, 2010

Data acquisition, solar

We all are trying to use alternative energy when we can at this point, arguably to save costs, but certainly to help with the various resource problems of the stupendous global overpopulation.

At any rate, lets look at a few options that might be available to us:

Energy Accounting
The first step in residential use, is determining usage. Once we know

A simple solar PV mat can charge your car battery or cell phone while it blocks the light from coming onto your dash. These

Thursday, April 1, 2010

PHP - MySQL arrays

PHP is a glue for many web sites. It shapes the pages of the browser interface, and also accomplishes interactions with the database, when needed.

The grist of Web activities involve databases. What comes out of and goes into a database during a web transaction often requires additional manipulation. Many times, these processes require arrays. Suppose we're using MySQL as a database, calling a few records to compare with some user-entered data. Sometimes the data can be manipulated on the hosting database server. More often, data is retrieved as an array and needs to be managed after it has been extracted. For example, it might be extracted with a PHP command, manipulated, and then the database might subsequently be updated.

Manipulating arrays is a core and somewhat complex PHP activity. Except for the complexity of security, arrays play a role in the most complex PHP functions. As noted above, user-entered data might be arriving from the browser side at the same time that info from a database is being extracted. In such a case, three or more arrays, even if temporary, might be created with PHP. PHP would also accomplish the comparisons, increments, and so on, that would take place with these arrays. If one can understand and write scripts to manipulate arrays, a programmer can quickly learn less complicated PHP functions.

Here are some resources for learning array-related PHP skills:
Dovlet Tatlok
WebMaster World
PHP Freaks
Big Resource
PHP Builder
reading directories