Recently in Tutorials Category

Quoted from http://www.jameslockman.com/jamesblog/2009/09/fix-for-perl-gd-imagemagick-an.html:

Fix for Perl, GD, ImageMagick and more on MacOSX Tiger Server - James Lockman's Blog

A week of frustration followed my attempt at upgrading my XServe G5 Dual Processor from Tiger Server to Leopard Server. Silly me, I made the bold assumption that Apple would have the decency to leave the underlying server parts untouched and add their secret sauce for blogs, ical, collaboration, and the like, on top of what was proven. What do I mean by proven, you ask?


How about perl, or PHP, or MySQL? I used to have a perfectly acceptable Movable Type blog (this one, in fact) running happy as a clam on this server. I had never been able to get ImageMagick to properly install, though, as well as some convenience modules like Compress, but hey, Leopard was going to make everything all better. However, when we (props to my son Arthur, whose patience and tenacity led to success) "upgraded," nothing worked anymore. The web is full of complaints about various pieces of this puzzle, so I will leave it up to you to go digging. As for my blog and other data-driven and dynamic graphics-based sites that used to reside on this server, they were defunct. Dead. Doornail dead.
GD is important, as is DBI, DBI::MySql, ImageMagick, PerlMagick, and others. Without them, the Blog just doesn't go. Of course, the major technologies like MySQL and PHP are essential, but the versions provided by Apple were either just plain broken, or were inadequate for the tasks at hand. Of course, we reinstalled!
MySQL and PHP installers are available and we installed them according to the clear instructions provided by MySQL.com and Marc Liyanage, respectively. The tricky part was getting the built-in PHP to shut off and the new one to turn on, but judicious application of the "refresh view" button on the server manager cured that.


Then we turned to MacPortsto install the additional modules. What a disaster.Not MacPorts, mind you, it performed admirably. None of the ports we installed appeared in the list of installed perl modules, despite getting successful reports from MacPorts. I admit that after a few days of banging my head against the wall, I had had enough.Giving up, we scrapped Leopard Server and went back to Tiger Server. But, we were still without some modules.


It turns out that Apple's installation location for the remaining items is not where the rest of the world expects them to be. In the case of perl, when we check our version with CPAN, it reports that we have the current version of perl, and that our modules are installed. We were successfully able to install modules, and they all appear to install without issue, except for PerlMagick, which reports a whole pile of errors. More on that later. When we run the mt-check.cgi from the Movable Type installation, however, we get paths to multiple perl installs, none of which are the current version. Clearly, there is some major confusion here.


The solution turns out to be easy: ditch Apple's mangled perl distribution and put in a link to the good, current installation in its place. The following two lines in the terminal move the old perl installation to a safe place where it can do no harm, and then create the appropriate symbolic link to the /opt/local/bin/perl folder, where we have all of our modules installed.

sudo mv /usr/bin/perl /usr/bin/perl.orig

sudo ln -s /opt/local/bin/perl /usr/bin/perl


Voila! All of my modules are now installed and available to MovableType. GD, DBI, DBI::MySQL, Compress, and all of the others we were lacking, except for PerlMagick.


Even though we used Ports successfully to install ImageMagick, PerlMagic fails, and it fails because of Apple's path problem. So, to install, download the tarball, then follow the instructions. Here's the key, though.
Remember the /opt/... directory? In the makefile.pl file, locate the LIBS and INC entries and change "usr/" to "opt/" in all of the path references in those two lines. Then, build as normal. Double voila!


Now, everything works as we expect it to. I can upload images and get thumbnails, I can connect to databases from my web sites and blog, and I believe that I can detect the aroma of rose coming from the exhaust fans of the XServe right about now.

,,,,

Contribute CS4 and Movable Type

| No Comments | No TrackBacks

As you all know, I run my blog on the Movable Type blogging platform. Until recently, the only applications that could connect to this blog were Ecto, which I didn't want to pay for, and Qumana, which doesn't look that good. The only other oprion was Contribute CS4, ahich I already had a license for. Up until now, Contribute has never connected to my Movable Type blog. It always errored out and wouldn't connect.

Until now.

I have no idea what I have done to make it work, but it does. So, I'll show you how.

When you open Contribute for the first time, it gives you the option to add a blog connection. Click on that link. You should get a window that looks like this:

In this window, you want to select the option to hook to "Other Blog Servers". In the field in the bottom, enter the address of your blog.

In the next pane, enter the username that you use to login to your site. PAY ATTENTION TO THIS STEP! Go into your Movable Type Administration panel, and go toyr user settings. Scroll down, and retrieve your Web Services password. This is the password that you enter into the password field in this panel. For the access point, you have to enter the path on your server to the file mt-xmlrpc.cgi. This file is usually located in the same folder as your MT installation. for example: http://www.yoursite.com/mt/mt-xmlrpc.cgi.

Once these steps are done, click finish. It will take a few minutes to build all of the required templates in order to build you a blog entry. NOTE: It will pull templates for all of the blogs that you have set up under your user account. This is handy for installations with more than one blog.

You are now ready to use Contribute CS4 to edit your Movable Type Blog. Have fun Blogging!

,,,

Looking to develop for iPhone?

| No Comments | No TrackBacks
One of the best resources that I have found if you want to learn how to develop for iPhone is found on iTunes U. The provider is Stanford University, and it is actually one of the classes that they offer, recorded and posted. CS-193P, to be exact. The class is taught mainly by apple developers, and is for everyone of all skill levels. It takes you through all of the basics for developing, and really teaches you well. I've found it to be a valuable resource that everyone should check out!

All for now!

iPhone Development on a Powerbook!

| No Comments | No TrackBacks
When Apple announced that it's iPhone SDK would not be supported on a PowerPC mac, many developers were highly disappointed. I was one of them. Well, it turns out that the iPhone SDK 2.2.1 and before, not 3.0, are actually universal binaries. It only took a few days for people to figure this out. Here's a detailed description of what do do from the Apokalypse Software Corp. 

Here's how you can install the iPhone SDK for 2.2.1 on a Mac running at least MOX 10.5.5:

1. Ensure you have at least 6 gigs of disk space available. If you have tried to install the iPhone SDK on the target volume before, it may state an upgrade will be performed instead of an install. Sadly, the only solution I currently have for this situation is to uninstall Xcode using /Library/Developer/3.1/uninstall-devtools.
2. Download the SDK disk image.
3. Mount the image by double-clicking it.
4. Copy the mounted volume to a hard drive.
5. Navigate to iPhone SDK.mpkg/Contents/iPhoneSDK.dist in the copied folder and replace line 340 which should be
start_selected = "isIntel() && hasRightOS() && agreedToSLA()"

with
start_selected = "true"

6. Run the installer, selecting either the default location /Developer or another directory name if you're looking to preserve your current Xcode installation.
7. After a successful installation, navigate from the installation directory (default of/Developer) to/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications/iPhone Simulator Architectures.xcspec, and make the following two changes.

First, replace

{ Type = Architecture;
Identifier = Standard;
Name = "Standard (iPhone Simulator: i386)";
Description = "32-bit iPhone Simulator architectures";
ListInEnum = YES;
SortNumber = 1;
RealArchitectures = ( i386 );
ArchitectureSetting = "ARCHS_STANDARD_32_BIT";
},

with

{
Type = Architecture;
Identifier = Standard;
Name = "Standard (iPhone Simulator: i386)";
Description = "32-bit iPhone Simulator architectures";
ListInEnum = YES;
SortNumber = 1;
RealArchitectures = (
i386,
);
ArchitectureSetting = "ARCHS_OLD_STANDARD_32_BIT";
},
{
Type = Architecture;
Identifier = Standard;
Name = "Standard (iPhone Simulator: ppc)";
Description = "32-bit iPhone Simulator architectures";
ListInEnum = YES;
SortNumber = 1;
RealArchitectures = (
ppc,
);
ArchitectureSetting = "ARCHS_STANDARD_32_BIT";
},

then, replace

{ Type = Architecture;
Identifier = i386;
Name = "Intel";
Description = "32-bit Intel";
PerArchBuildSettingName = "Intel";
ByteOrder = little;
ListInEnum = NO;
SortNumber = 105;
},

with

{
Type = Architecture;
Identifier = i386;
Name = Intel;
Description = "32-bit Intel";
"PerArchBuildSettingName" = Intel;
ByteOrder = little;
ListInEnum = NO;
SortNumber = 105;
},
{
Type = Architecture;
Identifier = ppc;
Name = "Minimal (32-bit PowerPC only)";
Description = "32-bit PowerPC ";
"PerArchBuildSettingName" = PowerPC;
ByteOrder = big;
ListInEnum = No;
SortNumber = 201;
},
{
Type = Architecture;
Identifier = ppc7400;
Name = "PowerPC G4";
Description = "32-bit PowerPC for G4 processor";
ByteOrder = big;
ListInEnum = NO;
SortNumber = 202;
},
{
Type = Architecture;
Identifier = ppc970;
Name = "PowerPC G5 32-bit";
Description = "32-bit PowerPC for G5 processor";
ByteOrder = big;
ListInEnum = NO;
SortNumber = 203;
},

Now go ahead and start Xcode and when you select the "File > New Project..." menu item, you should see a darling iPhone category for projects. Also, run the iPhone simulator in /(Xcode install path)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\\ Simulator.app, it's really mind-blowing to run it on your desktop, especially one Apple tells you isn't able to run their iPhone SDK.

End of Article-------------

I use this and it works great. Here's a screenshot of my computer running the iPhone Simulator 2.2.1 to prove that this actually works.

You should really use this if you're stuck on a PPC and want to make iPhone apps. It works Great!

Excellent iPhone Development Training

| No Comments | No TrackBacks
In my search for a good way to learn how to develop for iPhone, I have been directed to iTunes U. I then found an excellent podcast on iPhone development made by Stanford university. I highly recommend this podcast if anyone needs to learn development for iPhone.
So, you now have all this data into your Flex application from PHP, you would want to use this data. How do you do it? Well, in this part of the series, I will explain how to use text from PHP in your flex application.

First off: using plain text. Lets say that all that the PHP script returns is a big paragraph of text. To do this, you just make the PHP script print the text. Easy enough. Lets also say that the text is the classic: 
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam feugiat augue eu ligula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla vitae nisl. Ut fringilla. Nunc tincidunt nunc non magna. Duis vestibulum euismod ipsum. Praesent consequat. In ultricies, massa vitae consectetur accumsan, purus nunc adipiscing magna, nec gravida ipsum enim at quam. Nam in arcu. Donec id mauris in dolor gravida faucibus."
Since this is your text, and you are receiving it through an HTTPService in Flex, (Discussed Here) you have it easy. All you have to do is to access the result of your HTTPService, (lets say it's called dataService) by saying dataService.lastResult. You can use this snippet of code several ways. To get it to display in a text field, you just have to make the Text property of the label or text box this: {dataService.lastResult}. The control will now show the text that you fed it. 
this can be used on all kinds of controls all over your application.

I know I previously said that this entry would be longer. This was an outright fabricated lie. I have broken the entry up into two entries, one today, and one later on in the week about parsing Image data in your application from the PHP script.

Hang on till then.
So, if you have not seen part 1 of this series and are just now seeing part 2, the link to part 1 can be found here. Now for part 2. This part will be shorter, because there is less to talk about. Part 3 will be quite long and in depth, so keep up.

So now, you have a functioning PHP script that will generate XML code that Flex can interpret. So, for the sake of simplicity, lets say your XML consists of this code. 
<?xml version="1.0" encoding="utf-8"?>
<customer>
     <first>John</first>
     <last>Doe</last>
</customer>

So, that's the script that will be generated by your PHP script if you poke it. But, how do you get flex to poke it? Well, Flex has a built in component to handle this request. It is called an HTTPService. The HTTPService allows you to connect to a web page (PHP, XML, HTML, whatever..) and pull the results. So, to get the result from the PHP script, all you have to do is define an HTTPService component that connects to the PHP script. It would be done like so:
<mx:HTTPService method="POST" url="http://www.me.com/script.php" id="webService" /> 

This HTTPService call will ask the PHP script for a result, which will be supplied to it. The result will be enclosed in the result of the HTTPService. This is accessed by simply getting the name of the HTTPService, in this case webService and attach another identifier to it. This example would require somthing like this: webService.lastResult. Now, a certain tag in the XML code can be accessed by a different method. So, if you want to get the customer name, in this case John, you would do something like this: webService.lastResult.customer.first. Notice the names of the XML tags in the access tag. To access anything deeper, you would have to just add the next tag down and go from there. 

That concludes part 2, and part three will be here on Sunday. Hang on for then.

PHP Data with Flex Applications: Part 1

| 5 Comments | No TrackBacks
I will now start my 3 part series on connecting PHP/MySQL datasets with a Flex application. Part 1 will deal with writing the PHP back end script. 

To start, you need to know the PHP command  Print. this will give you the means to send along the data. You also need to know variables which will be used in the script. 

To start, you need to define a variable and give it a value. The value of the variable will be the beginning of your XML code. So, the variable should be called $result. Define $result like this:
$result = "<?xml version="1.0" encoding="utf-8"?>"; without this, flex will not be able to decode this data as XML. You need to put quotes around the text in the tag or PHP will not recognize it as text.

Next, you use the function that will append data to your variable. This is easy, and involves only adding a . to the end of a variable. So, to define your first XML tag, you do something like this:
$result. = "<myTag>"; which will add the <myTag> tag to your XML script.

So, you want to put MySQL or other data into the XML? Here's how! You have to know how to access the data. You would put it into the tag like this:
$result. = "<myDataTag>".$row_my_data['data']."</myDataTag>"; Notice the periods between the text and data. These will let PHP know that the data in the $row_my_data['data'] text will come from elsewhere in the script. 

To have multiple pieces of data in the same thing, like member names of an organization, all you have to do is to put a repeat region around one of the tag definitions. This will repeat the tag until there is no data left, or another user defined parameter. 

To finish it off, you have to make sure that you have closed all your tags. Otherwise, there will be an error. 

So now, the $result variable has all the XML data that you need. All you have to do is print it to the page. So:
print $result; will do the job.

In a few days, I will put up the second part of the series, "Receiving the Data in the Flex Application", followed by "Implementing Data in the Application".

Total Training a Huge Help

| No Comments | No TrackBacks
Even though I am only a budding Flex developer, I have found a couple resources to be useful. One is free, and is the Adobe Flex in a Week training online. This is great if you are one of those fast paced people. Not for me. Another is the Total Training for Flex 2 and 3. They are slower paced, and pack more information in to the training. There are 2 for Flex 2 at least, Rich Internet Applications and Advanced Visual Programming. The first one is more basic, and the second one is longer and more in depth. Hence the "Advanced".

Twitter

Follow arthurlockman on Twitter

Pages

Powered by Movable Type 5.01

About this Archive

This page is an archive of recent entries in the Tutorials category.

Training Resources is the previous category.

Twitter is the next category.

Find recent content on the main index or look in the archives to find all content.