Wednesday, February 20, 2013

Servlets in Eclipse

Update Eclipse so it can use Tomcat to Run Servlets

First, add ability to run servlet in Eclipse.
  1. Download Eclipse with Java EE.
  2. Add extensions for JAX-WS from
    http://wiki.eclipse.org/images/b/bf/Jaxws-1.0.0-201003201732.psf
  3. Add them to Eclipse with File->Import->Team->Team Project File. The username is anonymous and the password is an email address.
  4. Create a Dynamic Web Application. Create a New Runtime (Server) for Tomcat. Select Create local server, to save a step later.
  5. Create servlet from New -> Servlet.
  6. Works perfectly.
  7. After I had to restore my computer, the eclipse installation was no longer working. Tomcat was not recognized. I switched workspaces (File->Switch Workspace) and reinstalled the Tomcat plugin. It is working again, but there are still some red Xs for some packages.
JSPs in Eclipse
  1. Be sure that the project is using the Tomcat runtime.

Backspace in nano after ssh from Mac OS X

When I used ssh from a mac to connect to a remote linux machine, the nano editor did strange things to the backspace key.

It would work for three of four deletes, but then it would jump to the end of the line and start deleting there. It was very strange.

The TERM variable on the local machine is sent to the remote computer. Both machines were using xterm-256color.

I disconnected from the remote and set the TERM variable in the Mac terminal:

export TERM=xterm-color

I reconnected to the remote machine and the backspace worked properly.

Sunday, January 20, 2013

Running Different Version of Perl on Mac

Running Different Version of Perl on Mac

Upgrading the installed version of perl on a mac can create problems.

An alternative is to use Perlbrew. It allows other installations to be installed and used. New packages can be added to the active perl, without adding it to all perl installations.

Install with
curl -kL http://install.perlbrew.pl | bash

Once installed, initialize in .bash_profile with
source ~/perl5/perlbrew/etc/bashrc

Mac does not have a make command by default. It must be installed before installing any perl installations. It can be found in Xcode and then the command line tools.

I was able to get the command line tools without installing Xcode from
https://developer.apple.com/downloads/index.action?name=for%20Xcode%20-

Find the available perl installations with
perlbrew available

Install a version with
perlbrew install perl-5-16.2

Next, I tried to install cpanminus with
cpan App:cpanminus

It did not install. After switching to perl-5.16.2, it installed.

I am now able to install modules using cpanm into the current perl selected via perlbrew.

------------

I have created a bash script that allows me to switch to a different perl and create an alias named local for the new perl. I also have created a sym link in /usr/local/bin to the local alias. This allows me to change to any perl that I want and not have to change the shebang in the perl files. I use
#!/usr/local/bin/perl


#!/bin/bash

strip() {
    echo -e $1 | tr -d '\r'
}

#$1 is (out) selection, $2 is prompt, $3 is list of choices                                                         
readSelect () {
    local L_CHOICE L_LIST=`strip "$3"`

    if [ -n "$L_LIST" ]; then
        PS3="$2"
        select L_CHOICE in $L_LIST
        do
          if [ -n "$L_CHOICE" ]; then
            break;
          fi
          break;
        done
        eval "$1=\"$L_CHOICE\""
    else
        error "Nothing to select"
    fi
}

choices=`perlbrew list | grep -v "(" | sed -e 's/\* //g' -e 's/ (/_(/g' -e 's/^[[:space:]]*//'`
readSelect perl "Select perl installation: " "$choices"

echo "Setting $perl"

perlbrew switch $perl

perlbrew alias delete local
perlbrew alias create $perl local

Tuesday, August 7, 2012

Still Frames JPEG pictures: iMovie '11/QuickTime

Creating Still Frames as JPEG pictures in iMovie '11 and QuickTime

In previous versions of iMovie, it was easy to create still frames and export them as JPEG. There used to be a menu option 'View in Finder' that would do the trick. This menu option has been removed in iMovie '11. Some posts have indicated it is due to the fact that still frames are now small movies instead of single frames.

I follow these steps to create still frames from movies.
  1. Import the movies into iPhoto.
  2. Open iMovie and import the iPhoto movies into it. A dialog box should ask you to do this every time you open iMovie.
  3. In the clip area in the bottom, move to the frame that you want.
  4. Right-click (control-click) and select Add Still Frame to Project. This will add the still frame to the project area. 
  5. In the frame in the project area, select the drop down box and select Clip Adjustments.
  6. For the duration, change it to 1 second. The default for me was 4 seconds. Check the box for Applies to All Stills. When you export below, this will give you one picture for each frame.
  7. Repeat this process for all the stills that you want.
  8. Now it is time to create the JPEG pictures for each frame. Select the Share menu item from iMovie.
  9. Select Export using QuickTime.
  10. Select Movie to Image Sequence in the Export drop down box.
  11. Click Options.
  12. Select JPEG format and frames per second as 1. Combined with the length of the still frame from above, this will give you one picture per still frame.
  13. Click OK, then Save.
Update: When I created this post, I was using iMovie 11. Somehow, I am now using 10.0.9 and the option to Export does not exist, it has been replaced with Share. The Share menu does not have an option for QuickTime.

If I export to Image, then the first still frame will be created. For each still that I wanted, I added it to the start of the timeline and saved as an image. It is tedious. I have seen other posts for installing additional software, but this seems like such a natural thing to do that I cannot believe iMovie does not have a simple option.

Monday, July 23, 2012

Building a Firefox Add-on

I have just built a Firefox add-on using the Add-on builder.

Add-on builder is a web based tool that is easy to use to develop the add on. There is also the SDK which can be used to develop the add-on from the command line. I have not used the command line options.

https://addons.mozilla.org/en-US/developers/builder

Once there, select Try Builder. This takes you to a new page. At the top, select Sign-in. Once signed in, select Account to see the add-ons you have already created.

View the addon dashboard at
https://addons.mozilla.org/en-US/developers/addons

To publish at the dashboard, zip the contents of the extension folder (do not include the folder) and change the extension to .xpi.

I am using add-on builder, so I do not have the folder for the extension, but the .xpi file can be downloaded from add-on builder and then uploaded through the dashboard. Unfortunately, the link in add-on builder for uploading a new version does not work.

It seems that the add-on builder upload did work. When I did the manual upload, I received an error message that it was already uploaded.



Available Web Services

I am approaching web services from the stand point of a user.

I want to find useful web services and access them from a web application.

I do not care about all the different ways that web services can be implemented
or the history and development of web services over time. I want to be able
to consume a web service from a web application with as little coding as possible.
Link
My first thought is to be able to access a web service for a shipping company. I
will see if there are web services for UPS, FedEx and DHL.

I found a site for developers that want to incorporate FedEx services: http://fedex.com/us/developer/index.html. A similar site for UPS is https://www.ups.com/upsdeveloperkit. DHL offers this site: http://www.dhl.com/en/express/resource_center/integrated_shipping_solutions.html.

I had difficulty finding the WSDL address for FedEx. I found the following for UPS: https://www.ups.com/e_comm_access/laServ?CURRENT_PAGE=INTRO&OPTION=ACCESS_LICENSE&loc=en_US

There is a comment on the WSDL "Access to UPS shipping, tracking and payments. Free for use but you to apply, your company must already have an account with UPS and send a minimum of 50 packages per day." I will see if I am able to access it.

Created UpsWebService web application in NetBeans 7.0

Downloaded the Address Validation Developer's Guide, but it cannot be read.

Went back to FedEx and downloaded the Rate example.
  1. Using axis2-1.5.4.
  2. The classpath variables point to the wrong JAR files.
  3. Renamed obvious ones. Removed the others.
  4. Will try a compile to see what errors I get.
  5. Failure. The code is tied to axis2-1.4. Many changes for axis2-1.5.4.
I will try to find a Google WSDL to access.

I am using FedEx again and the Rate service. I will download axis-1.4
  1. I am reading the README file from the Rate example.
  2. I will add activation.jar and mailapi.jar to the classpath as well as the axis files.
  3. Added the .project file to Eclipse Helios. No compilation errors. I had to download activation.jar from oracle and add it to the axis lib folder. Same for mailapi.jar. Alternatively, I could have edited the variables that were created for the class path.
  4. Had to add -cp "\lib\*" to java command in order to get WSDL2java to run.
  5. All stubs are created and placed in workspace.
  6. Had to request access to test environment for FedEx. Only certified apps can run on production servers. Account number, meter number, key were in confirmation on web site. Password was only sent in email (that took 10 minutes to arrive).
Trying FedEx examples from NetBeans.
  1. Must use Axis 1.4 for library, not 1.6.
  2. mailapi.jar and activation.jar are there from Eclipse example.
  3. Success.
I will not try a different application using the NetBeans Services->Web Services.
  1. I have added a new Web Service in the Services tab for FedEx.
  2. I have linked to the wsdl that was sent in the samples from FedEx. The wsdl does not appear to be accessible from the web.
  3. Drag-drop getRates to example main program. There is not enough information to make a request that runs.
I will try creating a web service from a WSDL in NetBeans.
  1. New -> Web Service Client
  2. Local reference to WSDL from FedEx
  3. Same result as using Services.


I am now trying to use Amazon Web Services (AWS) to send bulk email.

I am following the instructions at http://docs.amazonwebservices.com/ses/latest/GettingStartedGuide/.
  1. The only glitch so far is that Perl needs to be installed in order to verify the email address.
  2. Next glitch, library LibXML.pm is missing.
  3. Could not find 64 bit XML/LibXML.pm. Am uninstalling 64 and installing 32 bit Perl.
  4. Still not luck. Trying to use cpan from perl install. Need C and make. Installing now.
  5. Installed cpanm and am installing XML::LibXML.
  6. Error about uninitialized value in Makefile.
  7. I am probably missing libxml2. This is a C library that implements GNOME functionality. I am trying to do the install in Linux. It may be better to rewrite the script using XPATH.
  8. Using Windows, I was able to run the email verify address by using XPATH. Listed after this list. Still didn't show results, I had to just view the plain text of the response.
my $xpath = XML::XPath->new( xml => $response_content);
$xpath->set_namespace('ns', $SES::aws_email_ns);

my @nodes = $xpath->findnodes('/ns:ListVerifiedEmailAddressesResponse' .
'/ns:ListVerifiedEmailAddressesResult' .
'/ns:VerifiedEmailAddresses' .
'/ns:member');

print "node count: @nodes";
foreach my $node (@nodes) {
my $text = $node->to_literal();
print "$text\n";
}

Have downloaded the SDK for AWS for Java.
  1. I have been able to send an email.
  2. I used ant. Now I am creating a project in NetBeans to run the samples.
  3. I created a library for AWS jar files in the lib and third-party folders of SDK.
  4. Updated my credentials and sent an email.
It only took a few hours to get moved to production mode.
  1. Created a utility class for adding recipients, reading recipients, etc.
  2. Sent bulk mail to mailing list with 50 addresses.
  3. Messages were received quickly.








Monday, June 4, 2012

Removing files from iPod Nano, Version 1.2

Removing files from iPod Nano, Version 1.2


By default, all files are synched to the iPod nano, so the only way to delete a file from the nano is to remove it from iTunes.

To change the default behavior, open the nano in iTunes. On the first screen, there are three check boxes that can change this behavior.
  1. Check the box "Sync only checked songs". After applying the changes, any file that is unchecked in iTunes will be removed from the nano on the next synch.
  2. Check the box "Manually manage music and video". This prevents automatic syncing and allows files to be deleted directly from the nano. There is a warning about having to eject the nano manually.
  3. Check the box "Enable disk use". This will allow files to be deleted directly from the nano, but will still allow syncing when the nano is connected to iTunes.
The second and third options allow the nano to be used a data disk. Files can be copied to the nano in Finder.

More Blogs

Followers