Matt Brown – Journeys of a software engineer

January 25, 2012

Database Reverse Engineering With Spring Roo

Filed under: Uncategorized — Tags: , , — mattbsoftware @ 11:51 pm

roo’s database-reverse command will not work out of the box because Spring doesn’t ship or make available an osgi driver for Roo due to licensing restrictions.



  1. get this pom
  2. mvn install
  3. start roo and run the following commands

osgi install --url file://{maven repo}/javax/resource/com.springsource.javax.resource/1.5.0/com.springsource.javax.resource-1.5.0.jar
osgi install --url file://{maven repo}/javax/transaction/com.springsource.javax.transaction/1.1.0/com.springsource.javax.transaction-1.1.0.jar
osgi install --url file://{maven repo}/com/oracle/roo/jdbc/

osgi start --url file://{maven repo}/javax/resource/com.springsource.javax.resource/1.5.0/com.springsource.javax.resource-1.5.0.jar
osgi start --url file://{maven repo}/javax/transaction/com.springsource.javax.transaction/1.1.0/com.springsource.javax.transaction-1.1.0.jar
osgi start --url file://{maven repo}/com/oracle/roo/jdbc/

Connect Roo to Oracle DB

  • get into roo (‘roo>’) and execute the following

project --topLevelPackage --projectName --java 6
persistence setup --provider HIBERNATE --database ORACLE
database properties set --key database.url --value jdbc:oracle:thin:@:1526:
database properties set --key database.username --value
database properties set --key database.password --value

The fun part

Enter the following command, and lean back.

database reverse engineer –schema –package

December 22, 2009

Nifty link for command line settings to customize your mac

Filed under: Apple, Uncategorized — mattbsoftware @ 11:24 pm

This site has some nice command line settings changes to make your mac more “pro”.  I especially dug the ability to add spaces to the doc.

PS: the end of 65 hour work weeks is in sight, expect some posts soon

August 1, 2009

Unit testing Google App Engine Task Queues and urlfetch

Filed under: GAE, Google — Tags: , , , — mattbsoftware @ 5:51 am

My app pulls a web page (urlfetch) and uses the Google App-Engine (GAE) taskqueue API, these were hard to emulate in my tests with the mock lib. This post is about how I solved the urlfetch, and taskqueue problem in unit tests.

I am writing an app that parses a web page and analyzes the data. I needed a better/faster way to iterate my test-debug cycles, than actually hitting my data source page.  Additionally I needed predictable content for my tests.  I am getting to know TDD at the day job (props to Saad-Zilla!!).   This app seemed like a great candidate for Unit Testing. I found the  GAE Unit Test framework and had some great results.   That framework runs all the tests and reports the red/green results at or http://localhost:<port>/test.   However I wasn’t so lucky in the mock dept. I tried a standard mock library, but ran into troubles with the mock library-pymock.

This is how I Unit Test taskqueue and urlfetch in my GAE app. I struggled with the pymock library, so I took advantage of Python’s dynamic language feature.  I simply created new classes that mock’d the objects needed for the test and implemented a simple proxy for urlfetch and the taskqueue.

  1. Get the GAE Unit Test framework from Google Code
  2. Download this zip, and lay it on top of the GAE sample project you download in step #1
  3. Check out proxy classes for TaskQueue (
    1. There is small issue in the taskqueue emulator, since it calls the next task in the list immediately , code after the add to the task queue will not run as it would out of the tests (see the code for more detail).
  4. Check out and urlfetch (
  5. Check out the tests in and
  6. Fix up the sample python code, I have only been using Python for a few months. I think the code could be made more python-like.
  7. red-green-refactor all the live long day 😉

PS: I am only 6 months into python, and that is only when away from the day job. I imagine the zipped code could be a little more Python-like. Please suggest better Python practices.

July 18, 2009

How I got a new Apple 32GB 3GS iPhone for ~$30

Filed under: iPhone — Tags: — mattbsoftware @ 8:56 pm
  • Have a 3G iPhone for 12-18 months
  • Pay AT&T more than $100 per month

I listed my 1 year old 3G 16GB for $300 on craiglist. Within 4 hours I had 40 offers, almost all saying “I have cash, where can we meet.” I got a little more than originally paid for the iPhone, in cash, and the buyer came to me.

Next, I went to the apple store and bought my phone for a net price of ~$30!!!!!
– $299 for 3GS/32GB
– $~30 fees
+$300 cash

April 29, 2009

Be Very Careful with iPhone Mobile Provisioning

Filed under: Apple, Certificates, iPhone, Mobile Provisioning — Tags: , , , — mattbsoftware @ 12:30 am

I have a new Mac Book Pro and have screwed it up twice by not carefully following instructions. I have been developing for iPhone with my iMac and wanted to be able to do the same on the MBP. At the end of both attempts my MBP could not see the iPhone, not even in iTunes. A reload of OS-X will bring the devices back, but may have other consequenses. I ultimately re-imaged my system and started over. Read on to avoid my pain.

The secret is to carefully, slowly follow the instructions.

This is super high level description, please read the Apple links below, they have the step-by-step instructions

These operations in the following order worked for me:

  1. Import private key for certificate – installed private key (double click *.p12 – add to login)
  2. Import certificate – installed cert – double click on *.cer – add to login
  3. Import mobile provision – drag and drop .mobileprovision file on to the xcode icon on the doc

Hints: store the above three files some where safe from destruction and prying hands. (Apple suggests an encrypted DMG)

I followed these steps:
1. Get your private key:
2. Dev Certificate and Mobile provision:

April 21, 2009

Home and End keys in Eclipse 3.4

Filed under: Eclipse, Keyboard — Tags: , — mattbsoftware @ 7:42 pm

Eclipse doesn’t honor the OS wide key dictionary settings. This URL has a little info –

However those instructions are for eclipse 3.2. In eclipse 3.4 do the following:

In Preferences|General|Keys

Home/End of line

  1. Find the ‘Line End’ command (use the filter)
  2. Copy the command (copy btn) – select the new version of the command.
  3. Click in the ‘Binding’ edit box.
  4. Hit the ‘End’ key
  5. Choose ‘Editing Text’ in the the ‘When’ combo-box.
Fix Text Selection
  1. Find the ‘Select Line End’ command
  2. Make sure it is selected and click the ‘Copy’ btn.
  3. Get focus in the ‘Binding’ edit box.
  4. Type a Shift+End
  5. Change ‘Windows’ to ‘Editing Text’ in the the ‘When’ combo-box.

Rinse & Repeat for Home – it’s key commands are ‘Line Start’ and ‘Select Line Start’

Home/End of text

  1. Find the ‘Text End’ command (use the filter)
  2. Copy the command (copy btn) – select the new version of the command.
  3. Click in the ‘Binding’ edit box.
  4. type ctrl+end
  5. Choose ‘Editing Text’ in the the ‘When’ combo-box.
Fix Text Selection
  1. Find the ‘Select Text End’ command
  2. Make sure it is selected and click the ‘Copy’ btn.
  3. Get focus in the ‘Binding’ edit box.
  4. Type a Ctrl+Shift+End
  5. Change ‘Windows’ to ‘Editing Text’ in the the ‘When’ combo-box.

Rinse & Repeat for Home – it’s key commands are ‘Text Start’ and ‘Select Text Start’

If anybody knows where this config info is saved please comment and I’ll drop the file somewhere so people can just d/l it. I couldn’t find it in my workspace settings.

April 5, 2009

How to get the IP address of an iPhone OS v2.2.1

Filed under: iPhone, Objective-C — Tags: , — mattbsoftware @ 11:35 pm

Lately I have been struggling with an iPhone OS 2.2.1 app that needs to know the WiFi IP address of the iPhone. Unfortunately at the time the app runs it does not have internet access and thus I cannot use

With thanks to Erica Sadun (iPhone cookbook) and gandreas and valexa on the iPhone dev forums I was able to create the following function. The function iterates over the IPs of the phone using getifaddrs(&addrs). if getWiFiIPAddress finds "en0" in the list interface addresses (ifaddrs) it will return the ethernet adapter zero (en0) IP address as a NSSring*. If no address is found the function will return NULL.

//------- includes

#include <ifaddrs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <arpa/inet.h>
#include <ifaddrs.h>

#if ! defined(IFT_ETHER)
#define IFT_ETHER 0x6/* Ethernet CSMACD */

//------- Implementation

- (NSString*)getWiFiIPAddress

BOOL success;
struct ifaddrs * addrs;
const struct ifaddrs * cursor;

success = getifaddrs(&addrs) == 0;
if (success) {
cursor = addrs;
while (cursor != NULL) {
if (cursor->ifa_addr->sa_family == AF_INET && (cursor->ifa_flags & IFF_LOOPBACK) == 0) // this second test keeps from picking up the loopback address
NSString *name = [NSString stringWithUTF8String:cursor->ifa_name];
if ([name isEqualToString:@"en0"]) { // found the WiFi adapter
return [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)cursor->ifa_addr)->sin_addr)];

cursor = cursor->ifa_next;
return NULL;

PS: I need a better blog, that support snippets – comments?

April 3, 2009

Doskey like tab completion and various other fixes /power user hacks for the mac console prompt (ctrl-left,right arrow)

Filed under: console, Keyboard — Tags: , — mattbsoftware @ 12:55 am

Want to have the same keystrokes (plus more) that are seen in M$ command/doskey or cmd on the mac console? Especially ctrl-left-arrow, ctrl-right-arrow. I did. Many years ago (Slackware v2) I started this .inputrc and have since updated and translated it for the mac console (Terminal.App).

For additional help “man bash” and search for “bind”. You will find the definitions of the commands in .inputrc (i.e. menu-complete). See the links at the end of the included .inputrc for additional help. These instructions are for the console, look here for fixing home and end in regular mac GUI applications: If your really curious about how all this works, “man stty”

This first part focuses on home and end, I put comments in the .inputrc that will explain all the other cool keystrokes.

Only two Steps:

  1. Change keybindings in Terminal.App
  2. Create/add to .inputrc


1. Change keybindings in Terminal.App
Goto Terminal’s Preferences. Select Keyboard. Find the end key and click Edit. Change the end key’s action to “send to string to shell”. You’ll notice that backspace/delete do not work properly. Use the Delete One Character button to backspace. Set the string to “\33[4~”

I had some issues typing the “\” character in the string to send edit box so I cut-n-pasted from some other random key and just changed the trailing end of the keycode.

Do the same thing for the home key, except use “\33[1~”. When your done Terminal’s preference’s should look something like this:

2. Drop this into ~/.inputrc ———————–————BOF
#”\e[11~”: “Function Key 1”
#”\e[12~”: “Function Key 2”
#”\e[13~”: “Function Key 3”

#”\e[14~”: “Function Key 4”
#”\e[15~”: “Function Key 5”
#”\e[17~”: “Function Key 6”
#”\e[18~”: “Function Key 7”
#”\e[19~”: “Function Key 8”
#”\e[20~”: “Function Key 9”
#”\e[21~”: “Function Key 10”

# For Bash, all terminals, add some Bash specific hacks.
$if Bash
“\C-xv”: show-bash-version
“\C-x\C-e”: shell-expand-line

### fix delete key
“\e[3~”: delete-char

## END key — MAC must be remapped in Terminal options (keyboard) “33[4~”
## HOME key — MAC must be remapped in Terminal options (keyboard) “33[1~”
“\e[1~”: beginning-of-line


# For FTP, different hacks:
$if Ftp
“\C-xg”: “get \M-?”
“\C-xt”: “put \M-?”
“\M-.”: yank-last-arg

” “: self-insert

$if Bash

# ctrl-backspace – none of this ever worked 😦 — use ctrl-w instead (default)
### never worked –>”\e\C-[D”: backward-kill-word
### Control-Rubout: backward-kill-word
##Map control-foward-delete to F14 “33[26~”
##”\e[26~”: backward-kill-word

#### doskey like completion
set completion-ignore-case On
“\e[A”: history-search-backward
“\e[B”: history-search-forward

#### doskey like line movement
#ctrl-left arrow
“\e[5D”: backward-word
#ctrl-right arrow
“\e[5C”: forward-word

# auto list tab completions
set show-all-if-ambiguous on

# show a filetype indicator in tab completions
set visible-stats on

## tab cycles through completions — I like the show-all-if-ambiguous instead
#”\t”: menu-complete
## shift-tab to reverse cycle complete
#\C-y: “\e–\C-i”

### didn’t like this
#Space: magic-space


# Include system wide settings which are ignored by default if one has their own .inputrc
$include /etc/inputrc

##helpful sites

If ~/.inputrc doesn’t work, then you need to add

export INPUTRC=~/.inputrc

to your .bashrc/.bash_profile

If your wondering why I am bother with home/end it’s because I use a M$ ergo keyboards on my macs. Why doesn’t Apple make one an ergonomic keyboard?

PS: Read-line keys natively work in man mac apps (ctrl+e for end / ctrl+a for end / ctrl+k for kill line, etc)

April 2, 2009

Colorful ls (dircolors) on a mac console (

Filed under: console, coreutils, ls — Tags: , , — mattbsoftware @ 1:55 am

On linux systems when I listed the contents of a directory (ls) I saw a colorful list. Different colors were used for compressed files, directories, images, etc.

Install GNU coreutils Steps:
  1. Download coreutils (I used v7.2). d/l site:
  2. untar it tar xzvf coreututils-7.2.tar.gz
  3. cd into the coreutils-7.2 directory
  4. ./configure –prefix=/usr
  5. make
  6. make check – (I had 2 test failures, but no problems)
  7. Install all GNU core utils by executing ‘sudo make install’
  8. OR just install ls and dircolors, and leave everything else BSD by copying ls & dircolors from ./src to /usr/bin
Setup bash_profile
  1. edit .bash_profile
  2. add these lines
#parses .dircolors and makes env var for GNU ls
eval `dircolors`

alias ls=’ls -hF –color=auto’

Setup .dircolors
————————————-BOF .dircolors
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the –color option.

# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.

# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM linux-c
TERM mach-color
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM xterm
TERM xterm-debian
TERM rxvt
TERM screen
TERM screen-w
TERM vt100

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory
LINK 01;36 # symbolic link. (If you set this to ‘target’ instead of a
# numerical value, the color is as for the file pointed to.)
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file

# This is for files with execute permission:
EXEC 01;32

# List any file extensions like ‘.gz’ or ‘.tar’ that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a ‘#’)

# If you use DOS-style suffixes, you may want to uncomment the following:
#.cmd 01;32 # executables (bright green)
#.exe 01;32 01;32
#.btm 01;32
#.bat 01;32

.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z 01;31
.Z 01;31
.gz 01;31
.bz2 01;31
.deb 01;31
.rpm 01;31
.jar 01;31
.dmg 01;31

# image formats
.jpg 01;35
.png 01;35
.gif 01;35
.bmp 01;35
.ppm 01;35
.tga 01;35
.xbm 01;35
.xpm 01;35
.tif 01;35
.png 01;35
.mpg 01;35
.avi 01;35
.fli 01;35
.gl 01;35
.dl 01;35

————————————————EOF .dircolors

All Done, type ls at a console prompt and your golden, or purple(directories), green(executables), etc…

– mattb

PS: Once an Apple update, updated ls, not problems, just remake and reinstall

PPS: A friend reminded me that if you want to keep BSD ls on your mac, you can simply alias ls=’ls- -G’ It is not as configurable that I know, but anything is better than colorless

Blog at