Java and .Net SOAP interoperability

June 10th, 2009 James Royalty Comments off

I came across a question on Stack Overflow today regarding SOAP interoperability between Java and .Net.  I posted this answer.  I don’t know if that solves the author’s problem, but it worked for me a few months ago.  So, if you are having problems consuming a Java SOAP service (running under Axis 1.x in particular) with .Net, check that post out.

Categories: Programming Tags: , ,

Happiness

June 4th, 2009 James Royalty Comments off

Most times, the best advice is the simplest…

Happiness is not a matter of intensity but of balance, order, rhythm and harmony.

– Thomas Merton

And it’s always very easy to see…

P050409SA-0939

Categories: Thoughts Tags:

otool: OS X equivalent of ‘ldd’

June 1st, 2009 James Royalty Comments off

I rarely do C++ development anymore, but today I had to dig around in some of our C++ code; I’m modifying the build to produce some new artifacts.  I work primarily on a Mac and secondarily on Linux.  Those familiar with Linux development tools probably know about ldd — it’s a simple tool that displays the shared libraries a given executable (or other library) depends on.  I was wondering if OS X had an equivalent… and it does: otool.  otool does a bit more than ldd, but if you just want to print dependencies like ldd does then try: otool -L file . For instance,

me@hubble:~$ otool -L /bin/bash
/bin/bash:
	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

And on Linux, using ldd, you get:

me@galileo:~$ ldd /bin/bash
	linux-gate.so.1 =>  (0xb8095000)
	libncurses.so.5 => /lib/libncurses.so.5 (0xb8052000)
	libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb804e000)
	libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7eea000)
	/lib/ld-linux.so.2 (0xb8096000)

For a list of other under-used OS X command line tools, check out Mac OS X Hacking Tools.

Categories: Programming Tags: , , ,

Adding version control info to your Bash prompt

May 17th, 2009 James Royalty Comments off

Last year there was a link to a blog post about displaying git info in your prompt floating around our office. We use Subversion at work so I whipped up a quick version for SVN. Nothing fancy, just a simple notification of when I’m sitting in a directory being tracked by SVN. Here’s the Bash code:

export PROMPT_COMMAND='_VC_LABEL= ;[ -d ".svn" ] && _VC_LABEL="[svn]"'
export PS1='\u@\h:${_VC_LABEL}\w$ '

which will produce something like

me@halley:~$ cd some-svn-dir
me@halley:[svn]~/some-svn-dir$

Love it or hate, Subversion makes this task pretty easy because each directory under its control contains a .svn sub-directory. So, all I have to do it check for the existence of .svn in the current directory. And voila.

Now, this weekend I took on the task of converting my personal Subversion repository over to Mercurial. I wanted to have similar functionality for directories under the control of Mercurial and keep the behavior for SVN as code from work is still in Subversion. Git and Mercurial both use a single control directory — .git and .hg respectively — in your project’s root directory. That means my simple method for Subversion wouldn’t work in this context; it would think you were in a version-controlled directory only if you were in your project’s root!

I took a look at the git-prompt project — which, from what I can tell, sprang out of the above-mentioned blog post — hoping to find a basis for Mercurial support. git-prompt is very full featured and even supports SVN beyond my simple implementation. However, one thing I didn’t like (besides not supporting Mercurial): It executes git/svn for every directory you enter. Ick.

So, my solution was to search up from the current directory looking for a .hg directory. If I find one only then do I execute hg to determine the branch info. Here’s the expanded version that supports both Subversion and Mercurial.

## Find a file or directory above current dir.  Stops at /.
function hq_find_parents() {
    local target="$1"

    local newpwd=`pwd`
    while [ 0 ] ; do
        local lookfor="${newpwd}/${target}"
        if [ "${newpwd}" == "/" ] ; then
            return 1
        elif [ -d "${lookfor}" ] ; then
            return 0
        elif [ -e "${lookfor}" ] ; then
            return 0
        fi

        # Now "move" UP one directory.
        newpwd=`cd ${newpwd}/..; pwd`
    done
}

## Set _VC_LABEL based on version control system.
function hq_vc_label() {
    if [ -d ".svn" ] ; then
        _VC_LABEL="[svn]"
    else
        local _hg=`which hg`
        if [ ! -z "${_hg}" ] ; then
            hq_find_parents ".hg"
            if [ $? -eq 0 ] ; then
                _VC_LABEL="[hg:`${_hg} branch 2>/dev/null`]"
            fi
        fi
    fi
}

_VC_LABEL=
export PROMPT_COMMAND='_VC_LABEL= ;hq_vc_label'
export PS1='\u@\h:${_VC_LABEL}\w$ '

Just add the above code to either .profile or .bash_profile and you’ll get something like this:

me@halley:~$ cd some-hg-dir
me@halley:[hg:default]~/some-hg-dir$
Categories: Programming Tags: , , ,

A past life, back up in

May 5th, 2009 James Royalty Comments off

I got a nice surprise recently. Turns out a research paper I worked on while in grad school was finally published!

Security in wireless sensor networks“, published in Wireless Communications and Mobile Computing.

Funny thing is, my research focus in grad school was artificial intelligence. :)

Categories: Computer science Tags: ,

FTP using Groovy and Ant

May 1st, 2009 James Royalty Comments off

Lately, I’ve been writing a lot of scripts in Groovy. Frankly, I love it. It’s easy to augment the functionality of your Java classes — implement interfaces, extend classes etc. Another nice feature is that Groovy allows you to leverage the power of Ant in your scripts using the AntBuilder object. I find this incredibly useful when doing off-liney, scripty things I’d normally do using bash combined with other Unix tools.

One common scripting task is to transfer a bunch of files to an FTP server. Here’s how I would accomplish FTP’ing *.gz files in the current directory using bash and curl:

for f in *.gz ; do
  curl -s -S -P - -T $f ftp.foo.com
done

Hard to beat for compactness. But, if you’re already working in Groovy, you can use Ant’s FTP task to accomplish the same thing. Here’s the Groovy code:

ant = new AntBuilder()
ant.ftp( server:"ftp.foo.com",
    userid:"user",
    password:"passwd",
    passive:"yes",
    verbose:"yes",
    remotedir:"/pub/incoming",
    binary:"yes" ) {
        fileset( dir:"." ) {
        include( name:"**/*.gz" )
    }
}

The verbose setting is helpful because otherwise the command’s operation is silent. With verbose enabled, output will be sent to stdout. All options supported by Ant’s FTP task can be used in the Groovy context. Furthermore, nested XML elements in Ant become closures in Groovy. (The fileset and include statements above.)

FTP is an optional Ant task so if you want to use it in your scripts, you’ll need the following dependencies on your classpath:

  • ant.jar
  • ant-nodeps.jar
  • ant-apache-oro.jar
  • ant-commons-net.jar
  • jakarta-oro.jar (at least version 2.0.8)
  • commons-net.jar (at least version 1.4)

I’ve tested this with Ant 1.6.5 only.

Categories: Programming Tags: , ,

Xcode and environment.plist

April 1st, 2009 James Royalty Comments off

For some reason I always launch certain applications via Spotlight as opposed to just dragging them to the dock and clicking on them there.  One such application is Xcode.  I’m not in Xcode every day (I’m normally writing stuff in Java and use Eclipse) so I guess it kinda makes sense.

Anyway…  Apparently, if you start Xcode via Spotlight your ~/.MacOSX/environment.plist file isn’t read. No doubt, something to do with how processes are launched via Spotlight. (Or rather, who launches them.)  I didn’t dig any deeper because I’ve got some work to do. :)

So there you have it.

Categories: Programming Tags: , ,

It’s like that

May 2nd, 2008 James Royalty Comments off

Here’s something I wanna remember.

…it’s like
learning to walk or swim or ride the bicycle, you just go
after it: it is a matter of learning how to move with
balance among forces greater than your own, gravity, water’s
buoyance, psychic tides: you lean in or with or against the
ongoing so as not to be drowned but to be swept effortlessly
up upon the universal possibilities

– Archie Ammons, Sphere: The Form of a Motion

Yeah, it’s like that.

Categories: Thoughts Tags: ,

P4P at Pando

April 9th, 2008 James Royalty No comments

I posted a write up today on Pandoblog.com about P4P. Check it out: P4P Behind the Scenes.

Categories: Programming Tags: , ,

P4P and Pando in the press

March 7th, 2008 James Royalty No comments

Work has definitely been busy of late. And being busy is good.

Most recently, I’ve been working on the tracker portion of our P4P implementation. P4P is a joint project with the P4P Working Group (which Pando co-founded) and Yale University. You can read about P4P via the previous link, but simply put, it allows for more ISP-friendly (and more efficient!) peer-to-peer traffic.

Hopefully I’ll have a bit more time to write about this soon. In the meantime, I’m very proud to say that last week, quite a few articles appeared in the press about P4P; among them are a spot in The New York Times, CNET and (for the geek in me) a post on Slashdot.

[Update] Looks like Laird posted about this too on our company blog. :)

Categories: Programming Tags: , ,