Adobe Flex and Soap Webservices
April 1st, 2008Although not specific to Mac OS X, Flex is a nice way to build cross platform applications. I decided to take a run at building a web application with Flex and a webservice. Check out the details.
Although not specific to Mac OS X, Flex is a nice way to build cross platform applications. I decided to take a run at building a web application with Flex and a webservice. Check out the details.
A colleague of mine wrote a little script for me. Actually two lines of shell. I needed to read a directory and get the last file and copy it. I was thinking I would do a readdir in perl, but he just fired up a shell script with ls into tail to grab the last jepg filename.
/usr/bin/ls *.jpg | tail -1
He set a variable with this filename and then just copied it. Pretty sweet.
Note, in this case the filenames worked due to the name format. However, you might have to add -tr (time reverse) to the ls command to get the files in the right order to grab the last one.
I downloaded the Adobe Air SDK so I could develop some Air applications, but once I downloaded it, was at sort of a loss for how to go about installing it. Their instructions are missing from the package and nowhere to be found on their site. I have a PPC mac, so these instructions should work for those with that configuration. If you have an Intel mac, I am assuming this would work for that as well. It should also work for other *nix type operating systems. Read the instructions
I needed a script to backup a workfolder to a Windows network server. I wrote this perl script that can be triggered using cron. First create a mount point. I used /smb/public. So to do so in two steps, mkdir /smb, then mkdir /smb/public. I put my scripts in ~/bin. Put this perl script below in ~/bin. Set the $folderToBackup variable. You’ll need to set the smb parameters. Fill in the username, password and share that you need to backup to. On your command line change directory to the ~/bin folder cd ~/bin. Then run it by typing this on the command line ./backupFolder.pl
#! /usr/bin/perl -w
##################my $folderToBackup = "/Users/bradrice/Documents";
##########################
#main package subroutines
sub mountDrive {
system('mount_smbfs //bradrice:password@SMBSERVER/SMBSHARE /smb/public');
}sub copyFiles {
system("rsync -auv $folderToBackup /smb/public/Documents/");
}sub unmountDrive {
system("umount /smb/public");
}mountDrive();
copyFiles();
unmountDrive();
I changed my rsync command to this: system("rsync -auv –modify-window=1 $folderToBackup /smb/public/BRice/"); in order to make my snyc not copy all the files every time. Apparently the windows machine sends back a different time format. See the rsync manual for that option. If this is run as a cron, the -v option which means verbose should be changed to -q for quiet.
I’m a big Adobe Illustrator user. But I realize that is a rather expensive program for the average mac user to have to penny up for. So I went in search of an application that could fill in for those who don’t have the resources. I came across a very capable program called Inkscape. It requires X11 to run. It is cross platform and runs in Linux, Windows and Mac. From my limited experience with it, the application has most of what you need to build web images. It even exports in .png. Read the rest of this entry »
I have been wanting a way to carry my passwords around with me. I purchased a USB card. The next step was to find a way to easily manage the passwords on the disk. After much searching, I found a java application, that has been written to work nicely with Mac OS X. It is called Universal Password Manager. It wasn’t written specifically for use on a USB flash drive, but after emailing the author, I found out that it could be easily be used that way. The application and the database it generates just has to exist on the drive. And the other requirement is that the machine you are intending to access the application has to be running java and that your java has the Java Cryptology Extension installed. The online user guide has links to java and JCE if you need them. I found that my standard Mac OS X java installation was sufficient to launch and use the application. It is packaged up as an app, so on Mac OS X all you have to do is double click to launch the application.
Read the rest of this entry »
I use cpan to install perl modules all the time. I recently installed Perl LWP. Unfortunately the install replaces and important text command file in /usr/bin. The file head was replaced by LWP head and this has caused some problems on my system. I found it out when I tried to install Sun’s Netbeans IDE on my mac. It wouldn’t launch. After submitting a bug request and going through the process with their tech, they discovered my head wasn’t the official one Apple ships. I did some poking around and found this on macosxhints: Perl LWP and head
I guess I have been having other problems, too. My system nighty scripts have not been running due to this issue. So if you have installed LWP, a very cool perl web library, be careful not to install the head. It asks you if you want to. Apparently I said yes during the install. If you do accidentally install it, you can copy it back from your install disk. It is in /usr/bin on the disk as it should be on your root drive.
I had a very large folder of images that I needed to build a tale of, as well as links for the images. I wrote a perl script to read the directory and build the table based upon the image file names in the folder. For our purposes here I am simplifying the script.
#!/usr/bin/perl
use File::Copy;my $columns = "5";
my $srcpath = 'pics/';opendir (SOURCEDIR, $srcpath) or die "Can’t open sourcedir " . $!;
my @comprehensivedir = readdir SOURCEDIR;
foreach my $file(@comprehensivedir){
if ($srcpath.$file){
push (@files, $file) unless $file =~ /^\./;
my $arrayRef = \@files;
}
}
my $length = @files;&chunkTabs(@files);
#iterate through the files and add them to the proper tags
sub chunkTabs(){
print "<table id=\"imageTable\" >\n";
for (my $y = 0; $y < $length; $y++) {
print "<tr>\n";
for (my $i = 0; $i < $columns; $i++ ) {
my $img_file = $files[$y];
if ($img_file){
print '<td class="thumbs"><img src="pics/'.$img_file.'" class="imageTable" /></td>'."\n";
}
else {
print '<td> </td>'."\n";
}
$y++;
}
$y = $y -1;
print "</tr>\n";
}
print "</table>\n";
}
I just launched Skim, the freeware pdf reader and was greeted with the install update screen. Apparently it is now up to 0.5. If you haven’t tried Skim and you do read pdfs, give it a try. It seems odd to me that Skim even exists. Adobe Reader is a perfectly good pdf reader and it is also free. But after you try Skim, if you have both Reader and Skim installed, you will probably finding yourself launching Skim to read. First off it is extremely fast and smooth running. Take a little time to look at the key command shortcuts. There is a little toolbar at the top, but if you use command 1 through 5 you can grab the tool you need. For example command-1 is the text tool and command-2 is the scroll tool. After you select the scroll tool, shift-down arrow makes the page scroll down. Just a down arrow takes you to the next section in the document as bookmarked. option right arrow takes you to the next page.
Skim also has the ability to add pdf notes to the page and save the document with them. You can add notes, lines, markup and circles. You can bookmark where you are on a book or document. Looks like one of the additions in version 0.5 is the ability to show or hide notes. If you read pdfs like I do, you may want to take a look at Skim. It truly is one of the cream of the crop applications that are Mac only.
I have to reprise a blog entry I had about Safari vs. Firefox. I have once again made the switch. I was using Safari for quite a while, and I still like Safari. It seems fast and responsive when rendering screens. However, the developer set in Firefox is invaluable. I work almost exclusively in Firefox now when developing a site. The developer tools are excellent, but the real gem now is Firebug. I have Firebug fired up constantly, turning on and off css and checking my dom.
I am having two problems with Firefox that I believe are only there for Mac versions. The scroll bar doesn’t always show the down arrow on certain pages. This sort of drives me nuts, because I like to use it to incrementally scroll down. Also, I occassionally lose my ability to tab from one field to the next. The only solution I can find is to reboot Firefox. Does anybody know about this? Anyone have a fix. I keep thinking they will fix it in a next release, but it doesn’t get fixed. It happens on multiple macs that I use, so it doesn’t appear to be my operating system.
Well, I implemented my bradrice.com front page to a drupal driven site. Please check it out. Drupal seems to live perfectly fine with any other pages you are serving or software living in the root folder. I decided for sanity sake to install it in a drupal folder and redirect to it. That way I will remember what folders need updated when I do update the software.
When I was considering different CMS packages to use for my site, I have to admit, the little blue drupal guy logo didn’t exactly make me feel confident. But I got past that.
I’ll still devote this Wordpress driven site to Mac and Unix articles. Drupal being open source and unix runs great on a mac. It can run on IIS with php installed. Refer to my main site for various other articles that may be of interest. I’m a web designer, so that site will cover more topics related to non-mac type development.
Drupal is a very active open source software community. That’s one reason I was led to utilize it. It’s well supported and constantly being improved by various developers. One thing you have to be careful about with an open source project like Drupal is the support you get, you have to verify it is good support. Somebody who uses Drupal and is part of the community may actually contribute bad help.
If you would have been considering Drupal, I would give it about 4 stars out of 5 so far. It was super easy to install. It takes some time to get a handle on all the options and controls. I like how it separates core code from code you can override, so you can extend it in many ways if you don’t want to use it straight out of the box.
I’ve been playing around with a new application called Incubator by a company called MindCad. It is a pretty cool brainstorming application when you need to branch categories or categorize things. You just double click on the page to add an item, or command double click to add a topic. Then you can slide your items around and have them chain together. Below is a very simple example of how it connects topics and items in a hierarchy.

Incubator is a little bit pricey for what it does. It is $49.00. I wrote a suggestion to the company and got a nice message back from the developers. So that is a good sign that the money paid is probably going back into the product.
I’m in the middle of a lot of changes. I recently changed positions in my career. I am still on a mac and intend to be. I’m at the University of Akron now, doing web design and development projects. I’ve come to look at web development from a whole new perspective. A website that supports such a large community is extremely hard to manage branding and content control. It’s the first time I have come to a site and had to manage it through a cms.
Akron U has developed it’s own PHP driven CMS. However, they are looking at other products. I have had a chance to review some products myself in the course of events. While I love Wordpress, I have found that Drupal is quite interesting and have begun to implement it. I’m hoping to have my main website up and running in drupal soon. I’ll continue to write Mac OS X and Unix tips and tricks in Wordpress, but run my overarching bradrice.com website in drupal.
I’m also working with Google Sketchup and Google Earth. Two very cool products. I’m going to be tracking the development on Google Earth and the Google maps api. It will be interesting to see if Google Earth eventually becomes a kind of browser plug-in, or if it will garner enough support as a standalone. It’s really quite amazing to see the 3D buildings take shape in different locations, cities, campuses and businesses. You can check out the Googleplex in Google Earth as an example, or type in Boulder Colorado in the search field and zoom in and see the sketchup models taking shape there.
I’ve been studying Information Architecture and how that relates to site building. Site maps, semantic web, dom, ajax and all kinds of good stuff like that. I hope to write more about those topics on my main site, while this blog will continue to focus on Macintosh and Unix as it relates to Mac OS X. One great thing about Mac OSX is that it is Unix at the core and most of the technologies I find interesting, run in Mac OS X.
Please visit both sites and book mark them.
Ever writing code and need to get a list of the input field names in your html document. I wrote this little perl script to parse out a list of names of the input fields.
#!/usr/bin/perl
open (INFILE, '
while ($line=) {
chomp $line;
my $input = $line;
if ($input =~ /input /
$input =~ /name=\”(\w*)\”/i;
$input = $1;
print “$input\n” ;
}
}
How it works:
Opens a file, reads it in line for line in the while loop. When it finds ”
input name=" and prints that value out after the equal sign. Assumes code is written as compliant html and uses double quote marks after name=
May seem simple to most folks, but just in case you are looking for an expression to remove the path before a file name here is an expression to start.
[\w/]*/
It searches for all the word characters before the last slash. If you need periods in the path add those to the character class.
I just updated my LAMP (Apache, MySql and PHP). I found that PHP installation can become problematic with MySql 5. Apparently the mac binary doesn’t include shared libraries. PHP fails when you build it against mysql. So I googled and found this excellent resource for helping you step through the installations. Start with Mysql and work your way down the installation links on the page.
I found a good way to make use of a scalar reference in perl. For development when you are using a dev and live server, you can change some settings using a ref.
Here’s what I did recently. In this case I needed two different mount scripts, one for a dev server and one for a live server. I stored each version of the applescript into a scalar variable. Then at the top of my script I set a variable called $deploy. I check $deploy to see if it is set to live or dev, putting a reference of the mount script into that variable. The subroutine then dereferences the mountscript and I get the Applescript I want. This way I can easily turn on dev or live with one variable at the top of the script. I don’t need to set up if else statements when I call the mountscript sub, it can contain the same argument scalar that dereferences at runtime.
##################
our $deploy = “dev”; # make it live or dev for testing or real
##################
#main package variables - need not be set manually
our $mountScriptDev = qq|
tell application “Finder”
–activate
try
mount volume “afp://10.1.4.220/fusionProJobs” as user name “me” with password “mypassword”
set mountvar to “FusionPro mounted”
on error
set mountvar to “mount failed”
end try
end tell
|;our $mountScriptLive = qq|
tell application “Finder”
–activate
try
mount volume “afp://10.1.4.230/D” as user name “me” with password “mypassword”
set mountvar to “FusionPro mounted”
on error
set mountvar to “mount failed”
end try
end tell
|;our $mountScript = ($deploy eq “live”) ? \$mountScriptLive : \$mountScriptDev;
##########################
#main package subroutines
sub AppleScript {
my($script) = shift @_;
system(qq|/usr/bin/osascript -e ‘$script’|);
}sub mountDrive {
&AppleScript(${$mountScript})
}
What a pain. Even CPAN couldn’t help. I love using CPAN for installing perl modules. It is usually a seemless operation. But DBD::Mysql on Mac OS X just wouldn’t go for me. I am installing in the usual location for a standard install - /usr/local
What I eventually had to do was this to get it to install:
sudo perl Makefile.PL –cflags=”-I/usr/local/mysql/include -Os -arch ppc -fno-common” –libs=”-L/usr/local/mysql/lib -lmysqlclient -lz -lm”
After that the make and sudo make install worked fine. I have a G4 thus the -arch ppc. If you have and intel mac, change that to -arch i386.
If you run it without putting the –cflags and –libs you will notice the paths are /usr/local/mysql/include/mysql and /usr/local/mysql/lib/mysql.
For some reason the default install has an extra directory mysql on the end of each path. I hope this helps if some of you are banging your heads to get DBD::Mysql to install.
One thing nice about Mac OS X are the avenues for development. There is Perl, PHP, Python, Ruby, C, Objective C, java, javascript, applescript and shell, just to name some of the possibliities. One of the things I have always wanted to be able to do, was to write .asp and test it on Mac OS X. While I’ve yet to find a free open source way to do that, there is now a way to develop for C# .Net applications on Mac OS X. It is a project called mono. Mono is a Unix implementation of Microsoft’s .NET Development Framework. Currently it is a ASP.NET 1.0 framework, but ASP.NET 2.0 is in the works. If you are a hard core .NET programmer, this will probably not be a satisfactory way to go. Get a PC with Microsoft Visual Studio. But for somebody who is on Mac OS X this is a nice way to wade into .NET development.
Oreilly has a book out called Mono Developer’s Notebook to help you learn how to use mono.
On another note, my previous post disucssed my frustration with spam comments on my blog. I’ve re-enabled comments on a per message basis for a while to test a new spam blocking feature I am trying. If you are a legitimate commenter, I would love to hear from you.