Monday, December 10, 2007

Ruby Calnder plugin

New day new problem.

I installed a ruby on rails calendar plugin. Install worked fine. One of the install steps was to run

rake rdoc

This gave me the following problem
rake aborted!
no such file to load -- hoe
C:/dev/ruby/timesheet/vendor/plugins/calendar_helper/rakefile:4
(See full trace by running task with --trace)

Hoe it turns out is a simple ruby project for helping with rakefiles. To install Hoe

gem install hoe
(no need for sudo since I'm on windows)

Now rake rdoc gives me
rake aborted!
couldn't find HOME environment -- expanding `~/.hoerc'
C:/dev/ruby/timesheet/vendor/plugins/calendar_helper/rakefile:7:in `new'
(See full trace by running task with --trace)

This was because I was running on Windows not unix. Setting HOME environment helps this

set HOME=%HOMEPATH%

Now the problem is
rake aborted!
Don't know how to build task 'README'

This as it turns out was a problem with the rakefile. It referred to a non-existant file 'README ' in the plugin. There was however a Readme.txt file. Updating the Rakefile to refer to this finally fixed the issues.


require 'rubygems'
require 'rake'
require 'rake/rdoctask'
require 'hoe'
require './lib/calendar_helper.rb'

Hoe.new('calendar_helper', CalendarHelper::VERSION) do |p|
p.rubyforge_name = 'seattlerb'
p.author = 'Geoffrey Grosenbach'
p.email = 'boss AT topfunky.com'
p.summary = 'Generates a configurable, CSS-tagged HTML calendar.'
p.description = "A simple method to create an HTML calendar for a single month. Can be styled with CSS. Usable with Ruby on Rails."
p.url = "http://rubyforge.org/projects/seattlerb"
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
p.clean_globs = ['test/output']
end

# desc "Test task (actually runs specs)"
# task "test" do
# system "spec --format specdoc --color spec/*_spec.rb"
# end

# -- Rails-specific --

desc 'Generate documentation for the calendar_helper plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'CalendarHelper'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('Readme.txt')
rdoc.rdoc_files.include('lib/**/*.rb')
end

Sunday, December 09, 2007

Ruby on Rails install headaches

Some problems installing ruby on rails that I thought I's document.

Firstly I followed the instructions on rubyonrails.org, downloading the altest version of ruby 1.86_25, downloading and installing ruby Gems. The the next step where you actually install rails is where the trouble started

C:\apps\ruby186.25\rubygems-0.9.5>gem install rails --include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Bad file descriptor - connect(2) (Errno::EBADF)


First problem was web proxys.

My laptop is used both in work and at home. In work I use a http proxy to access the web. At home I don't. The problem was I had set a system variable to set a http proxy variable. (http_proxy), but I was using my laptop at home.

To check if you use a http proxy from a DOS window type the following

echo %http_proxy%

If you get a response like
http://10.105.24.70:8080

then you have a http proxy set.

For me I had to remove the proxy. This is done by
set http_proxy=

For most people however I would imagine the problem is the opposite, you may need to set the http_proxy for your DOS window. To check if you need a http_proxy, goto your web browser

For IE
Tools/ Internet Options/ Connections/ LAN Settings/ Proxy Server
Note the url and port

For Firefox goto
Tools/ Options/ Advanced/ Network tab/ Settings (phew)
Note the url and port

You can set the proxy in the dos window simply by typing
set http_proxy=http://10.105.24.70:8080

With this done you should be able to retry the install

Next problem was

C:\apps\ruby186.25\rubygems-0.9.5>gem install rails --include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
OpenURI::HTTPError: 404 Not Found reading http://gems.rubyforge.org/gems/activesupport-2.0.1.gem


THis was a temporary problem. I inserted the url into a browser and it worked. When I retried the command it also worked.

Thursday, December 06, 2007

Oracle version

Ever wondered what version of oracle you were running?

Wonder no more

select name from v$database
select * from v$version

Monday, August 20, 2007

Working with saxon

Saxon didn't like the concatenation of the sequence. changing this to fn:string-join worked however.


declare namespace xf = "http://tempuri.org/xqueryTest/XQueryTransformations/csv/";

declare function xf:csv($aPIMessage1 as element(APIMessage))
as xs:string {
fn:string-join(
for $line in $aPIMessage1/AuthResponse
let $ct := concat($line/ClientTransactionReference, "," , $line/SystemReferenceNumber, ",", $line/ResponseInfo/ResponseCode , ",", $line/ResponseInfo/Result ,",", $line/ResponseInfo/Description , ",", $line/ApprovalInfo/ApprovalCode , ",", $line/ApprovalInfo/DateTime, " ")
return $ct,"")
};


declare variable $aPIMessage1 as element(APIMessage) external;

xf:csv(doc("./resp.xml")/APIMessage)

My first xquery; xml to csv

Got this working. Thought I'd post it. My first xquery. Parses an Xml response file (from a credit card authorisation system), and outputs some of the fields as a csv file. It was written using the BEA XQuery Mapper, which is a pluggin by BEA for eclipse 3.1.

Having an issue running it with Saxon at the moment


declare namespace xf = "http://tempuri.org/xqueryTest/XQueryTransformations/csv/";

declare function xf:csv($aPIMessage1 as element(APIMessage))
as xs:string {
concat(for $line in $aPIMessage1/AuthResponse
let $ct := concat($line/ClientTransactionReference, "," , $line/SystemReferenceNumber, ",", $line/ResponseInfo/ResponseCode , ",", $line/ResponseInfo/Result ,",", $line/ResponseInfo/Description , ",", $line/ApprovalInfo/ApprovalCode , ",", $line/ApprovalInfo/DateTime, " ")
return $ct)
};



declare variable $aPIMessage1 as element(APIMessage) external;

xf:csv($aPIMessage1)

Friday, May 25, 2007

Ibatis problem

Document root element "sqlMap", must match DOCTYPE root "null"

This was the unhelpful exception I was gettign when I tried to run my ibatis/ spring prototype.

My ibatis sqlMap file looked ok

<sqlmapconfig>
<sqlmap resource="db/prov.xml">
</sqlmap>
<sqlmapconfig>javascript:void(0)
Publish Post

Had a search, you must add

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">

to your sql map files

Note you must also have

<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">

to your sql-map-config.xml file.

Tuesday, January 30, 2007

java http proxy support

Heres a good post on getting java to use the host machines proxy settings

http://weblogs.java.net/blog/kohsuke/archive/2005/08/we_deserve_a_be.html

Upshot is to include the following in you java prog before making http requests

try {
System.setProperty("java.net.useSystemProxies","true");
} catch (SecurityException e) {
; // failing to set this property isn't fatal
}
Sweet!