Thursday, 10 December 2015

How to get Git using https:// instead of git://

The company network may have blocked the git:// protocol and a package manager like ngm may fail when attempting to update dependencies.

You can get Git to automatically use https:// instead of git:// in URL's.

git config --global url.https://.insteadOf git://

Monday, 9 November 2015

Installing POCO C++ Libraries on MacOS X

Current OS version is 10.11.1.
Current Xcode version is 7.1 (7B91b)

You need GNU make version 3.80 (or newer). On my Mac it is found as 


$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0


I downloaded the current version of the libraries from pocoproject.org and moved it to a subdirectory under /Users/robert

$ gunzip poco-1.6.1.tar.gz
$ tar -xf poco-1.6.1.tar
$ cd poco-1.6.1
$ ./configure
$ make -s
$ sudo make -s install

Sunday, 8 November 2015

Installing C++ Boost libraries on MacOS X

This post describes installing Boost on iMac.

Current OS version is 10.11.1.
Current Xcode version is 7.1 (7B91b)

I already have Apple´s SDK Xcode installed. It is free and can be downloaded from App Store. To use it we have to read and accept their license terms, otherwise the bootstrap'ing fails later.

$ sudo xcodebuild -license

I wanted to install the include-files and libraries of boost to /usr/local. 

These are the steps I went through:


Download and unpack Boost from www.boost.org. Current release is Version 1.59.0. I moved the download file boost_1_59_0.tar.bz2 to a directory under my home directory /Users/robert. I will refer to it as /path/to/boost. I decided not to store the whole installation under /usr/local.

$ cd /path/to/boost
$ tar --bzip2 -xf ./boost_1_59_0.tar

To generate the build script issue the commands.

$ cd boost_1_59_0
$ ./bootstrap.sh --prefix=/usr/local


If the toolset darwin is not automatically detected, it may be due to lack of Xcode installation.
If successful you can now build the boost libraries using

$ ./b2 stage

I get a lot of compiler warnings about BOOST_DO_JOIN etc., but no errors at this time. This will build the libraries into subdirectory stage. If successful you can issue the following command to install into /usr/local which was specified using the --prefix option. Use sudo to allow for writing to /usr/local.

$ sudo ./b2 install


Tuesday, 21 October 2008

Accessing Session from a Grails Service

Grails makes the session object (instance of the Servlet API's HttpSession class) directly available in the Controllers and Tag Libraries.

Furthermore, the Grails implementation of HttpSession allows you to access the session as a Groovy map.

session.user = "Robert"

will store a user name in the session's attribute list.

I wanted to encapsulate session data in a service and avoid defining session properties many places.

However, the session is not directly available in a Grails Service. So if you want to access the session from a Service, you do it via the RequestContextHolder class (part of the Spring framework).

Here is simple Service that does exactly this:

import javax.servlet.http.HttpSession
import org.springframework.web.context.request.RequestContextHolder

class SessionStorageService {

static transactional = false
static scope = "singleton"

def setUser(User user) {
getSession().user = user
}

def getUser() {
getSession().user
}

private HttpSession getSession() {
return RequestContextHolder.currentRequestAttributes().getSession()
}
}

This service is made available in Controllers by automatic dependency injection by placing a property in the controller with the name sessionStorageService:

class BaseController {
def sessionStorageService
...
sessionStorageService.setUser("Robert")
...
}
Any comments or suggestions are appreciated .

Monday, 29 September 2008

First Blog ...

Primarily a Java Developer's Blog. I will be using this to share my experience with software development technologies and as a notebook to remember ...

Keywords are: Grails, Groovy, Java, Hibernate, Spring, ActorFrame