ANT deployment script and SFTP

My development team is moving away from developing on mapped drives/file shares to using cloud-hosted servers on Amazon Web Services (AWS). This is introducing a change to our usual workflow, as our access to the remote servers is limited to SSH and SFTP.

Although I previously used Apache Ant scripts through Eclipse to facilitate deploying application updates, the scripts were generally unpopular with the rest of the development team. (Many of them do not use Eclipse and preferred just to drop-and-drag files from their development sandboxes to the development or production servers.) Additionally, my original Ant scripts relied on the sync command to synchronize folders on the file shares.

Here is a revised Ant script that uses SCP (Secure Copy)–not SFTP but achieves the same goal–to deploy application files from a developer sandbox to the development or production server:

<project name="Deploy myapp" default="Sandbox to Dev">
  <input message="Username:" addproperty="username" />
  <input message="Password:" addproperty="passwd" />
  <property name="applicationFolder" value="myapp"/>
  <property name="site" value="osric.com"/>
  <property name="sandboxRoot" value="${basedir}"/>
  <property 
    name="development" 
    value="${username}:${passwd}@dev.osric.com:/home/web/${site}/${applicationFolder}"/>
  <property 
    name="production" 
    value="${username}:${passwd}@osric.com:/home/web/${site}/${applicationFolder}"/>
  <target name="Sandbox to Dev">
    <scp todir="${development}" trust="true">
      <fileset dir="${sandboxRoot}">
        <exclude name="**/build.xml"/>
        <exclude name="**/.*"/>
      </fileset>
    </scp>
  </target>
  <target name="Sandbox to Production">
    <scp todir="${production}" trust="true">
      <fileset dir="${sandboxRoot}">
        <exclude name="**/build.xml"/>
        <exclude name="**/.*"/>
      </fileset>
    </scp>
  </target>
</project>

There are a couple issues with this script to be aware of:

  • SCP is not included with Ant. The script produced the error “Problem: failed to create task or type scp”. I needed to:
    1. Download JSCH
    2. Place the file in Eclipse’s plugins/[ant folder]/lib folder
    3. Add the JAR file to the Ant build path (via Window–Preferences–Ant Home Entries (default)–Add External JARs…–select the jsch .jar file)
  • The password input is in plain text. Hiding password input in Ant provides a solution for Ant, but one that does not work from Eclipse. I have seen other possible solutions, so I’ll update this once I implement once and confirm that it works.

Set difference of two lists using BASH shell

Recently a handful of e-mail messages went undelivered due to some mis-communication between 2 servers.

One server had a record of all the addresses it thought it sent to over the period of time in question, and the other server a record of all the addresses to which it had actually delivered (including messages from several other servers).

I had both lists, but what I really wanted was just the set difference: only the elements of the first list that did not appear in the second. (In other words, a list of the recipients whose messages were never delivered).

I had two files:

  • possibly-delivered.txt
  • definitely-delivered.txt

First, the possibly-delivered.txt file had a bunch of extraneous lines, all of which contained the same term: “undelivered”. Since that term did not exist in any of the lines I was looking for, I removed all the lines using sed (stream editor):

sed '/undelivered/d' possibly-delivered.txt > possibly-delivered-edited.txt

I already knew (from prior investigations) that there should be 204 addresses in that list, so I performed a check to make sure there were 204 lines in the file using wc (word count):

wc -l possibly-delivered-edited.txt

204 lines returned. Great! Now, how to compare the 2 files to get only the results I wanted?

With a little help from Set Operations in the Unix Shell I found what I needed–comm (compare):

comm -23 possibly-delivered-edited.txt definitely-delivered.txt

However, comm warned me that the 2 files were not in sorted order, so first I had to sort them:

sort possibly-delivered-edited.txt > possibly-delivered-edited-sorted.txt
sort definitely-delivered.txt > definitely-delivered-sorted.txt

Again:
comm -23 possibly-delivered-edited-sorted.txt definitely-delivered-sorted.txt

This returned zero results. That was not possible (or at least, highly improbable!), so I checked the files. It looks like the sed command had converted my Windows linebreaks to Unix linebreaks, so I ran a command to put them back:
unix2dos possibly-delivered-edited-sorted.txt

Again:
comm -23 possibly-delivered-edited-sorted.txt definitely-delivered-sorted.txt

That returned my list of addresses from the first list that did not appear in the second list. (Quickly, accurately, and without tedium.)

Find Feature UI annoyance in Adobe Acrobat Pro

The Find feature in Adobe Acrobat Pro X has bothered me for some time now:

Adobe Acrobat's Find feature: note the size of the click-targets
Adobe Acrobat’s Find feature: note the size of the click-targets

The click-targets to find the previous or next occurrence of your search term are tiny. Minuscule. Verging on microscopic. Let’s say I’m searching a 600 page PDF on SharePoint and I’m looking for occurrences of the term workflow. As I click next repeatedly, trying to find the relevant section, I find that it’s very easy for my cursor to edge over just a little bit and close the Find dialog.

(Yes, I know: I can just keep pressing Enter and avoid this issue.)

Vizio Co-Star’s Google TV versus Apple TV

What kind of crazy person buys both a Vizio Co-Star (Google TV) and an Apple TV?

Apparently, I’m that kind of person.

Vizio Co-Star and Apple TV

I’ve had the Vizio Co-Star for 3 months, and the Apple TV just for a couple days. Maybe that’s a source of bias, but the summary version is, despite its shortcomings, I think Vizio Co-Star provides a superior experience.

Now for the long version: Continue reading Vizio Co-Star’s Google TV versus Apple TV

Balancing Tags in HTML and XHTML Excerpts

It is fairly common to want to take an HTML source of variable length and display an excerpt. Although some formats, such as Atom and RSS, anticipate this and create a separate summary element, we don’t always have the luxury of using such a data source.

Creating an excerpt introduces a problem, though: if we create an excerpt based on a number of words or characters, we may end up with unbalanced HTML or even broken tags.

One solution is to discard all tags and display plain text, but this is often unsatisfactory.

Here is my method of balancing tags. It assumes that the input is an excerpt of a valid XHTML snippet. The reason for this requirement has to do with self-closing tags, which I hope will be apparent from the description:
Continue reading Balancing Tags in HTML and XHTML Excerpts

SharePoint 2010 Cross-Site Lookup using PowerShell

A common SharePoint request is to create a lookup field from a list in another site. This is possible so long as the sites are within the same site collection, but it does require some customization.

Since I am dealing with a single-server farm, I was able to do this fairly quickly in PowerShell:

# Set the site collection in which the source and destination webs exist
$site = Get-SPSite("https://mysite/path/")

# Set the source web to the web where the source list exists
$sourceweb = $site.OpenWeb("sourcepath")

# Set the destination web to the web where you wish to add the lookup
$destinationweb = $site.OpenWeb("destinationpath")

# Set the source list to the list in which the field exists
$sourcelist = $sourceweb.Lists["List Name"]

# Set the source field to the field you wish to perform lookups on
$sourcefield = $sourcelist.Fields["Field Name"]

# Get the collection of all fields in the destination list
$destinationfields = $destinationweb.Lists["List Name"].Fields

# Add a lookup field to the fields collection
# See the SPFieldCollection AddLookup(String,Guid,Guid,Boolean) method
# For details: http://msdn.microsoft.com/en-us/library/ms430950.aspx
$lookupname = $destinationfields.AddLookup($sourcefield.Title,$sourcelist.ID,$sourceweb.ID,false)
# The above produces an error: Missing expression after ','. At line:1, char:83
# Right--in Powershell, $false is False.
$lookupname = $destinationfields.AddLookup($sourcefield.Title,$sourcelist.ID,$sourceweb.ID,$false)

# Get the newly-added lookup field
$lookup = $destinationfields.GetFieldByInternalName($lookupname)

# Set the lookup field to the internal name of the source field
$lookup.LookupField = $sourcefield.InternalName

# Update the lookup -- without this the previous changes won't be saved
$lookup.Update()

# Dispose of the SPWeb and SPSite objects
$sourceweb.Dispose()
$destinationweb.Dispose()
$site.Dispose()

Oracle stored procedures and ColdFusion

I’ve heard for years that using Oracle’s stored procedures is both more efficient and more secure than writing queries against the database. It turns out, not everyone agrees with that and there is quite a bit of room for debate (most of the articles focus on MS-SQL Server and T-SQL, not Oracle and PL/SQL, although some general principles still apply):

I was still interested in how to use Oracle stored procedures with ColdFusion, though.
Continue reading Oracle stored procedures and ColdFusion

JAWS Screen Reader Reads Hidden Span in Internet Explorer

5 years ago, Juicy Studio posted in the article Screen Readers and display: none that the JAWS Screen Reader reads the content of hidden span elements on a page when used with Internet Explorer.

Although a subsequent article (JAWS, Window-Eyes and display:none: Return to 2007) suggests that this issue has been resolved in JAWS version 12 when used with Internet Explorer 9.

I have not yet tested this in Internet Explorer 9, but I noted that there is still at least one issue when using JAWS 12 with Internet Explorer 8: the title attribute of a hidden span element is read aloud. For example, take the following HTML:

<p>Paragraph element. You should hear this text.</p>
<p>Paragraph element. You should hear this text. <span style=”display:none”>Hidden span element. You should not hear this text.</span></p>
<p>Paragraph element. You should hear this text. <span title=”Title attribute of hidden span element. You should not hear this text.” style=”display:none”></span></p>

I expected to hear exactly what is displayed on-screen:

  • Paragraph element. You should hear this text.
  • Paragraph element. You should hear this text.
  • Paragraph element. You should hear this text.

Instead, I hear:

  • Paragraph element. You should hear this text.
  • Paragraph element. You should hear this text.
  • Paragraph element. You should hear this text. Title attribute of hidden span element. You should not hear this text.

I don’t know for certain that this is unexpected behavior, although I know that I personally expected different behavior.

How Many People Does It Take To Silence an Alarm System?

This is my fourth logbook entry for my Human-Computer Interaction (HCI) course.

A few weeks ago on a Sunday morning, a piercing, ear-splitting din pervaded my apartment: the fire alarm. This is not anything like your typical household smoke detector: smoke detectors are merely loud. This sound causes pain. We managed to scoop up the cat and shove her into her carrier and head outside. Fortunately, it was a false alarm: workers in the restaurant on the ground floor of my building accidentally triggered the alarm system.

The fire department arrived and confirmed that, indeed, there was no fire. However, they did not have the code to turn off the alarm. Neither did the employees at the restaurant. I called the maintenance number for our building who relayed the top-secret code that would reset the alarm: 1-2-3-4.
Continue reading How Many People Does It Take To Silence an Alarm System?

Big Belly Trash Cans and Usability

This is my third logbook entry for my Human-Computer Interaction (HCI) course.

A few years ago, Philadelphia replaced many of the garbage cans with BigBelly Solar trash compactors.

Big Belly Solar Trash Compactors
2 recycling bins and a solar compactor in Penn Park

I’d first seen Big Belly at a park in Chicago. It seemed like a great idea: the smart trash can compacts refuse so that it needs to be collected less frequently, and even sends out a signal to the grounds crew when it is full, so that there’s never an overflowing trash receptacle (the latter was a big problem in Philly, especially on weekends).

Time Magazine recently ran an article on BigBelly (“Trash Talk“), particularly citing their success in Philadelphia. I still think the solar compactors are a great improvement over the overflowing trash cans of years past. The streets are cleaner, and they save money. But from a resident’s perspective, I think they have room for improvement.
Continue reading Big Belly Trash Cans and Usability