I cannot stand being advertised to.
This is an easy fix for getting rid of all ads in Skype (6.11)
Just edit your hosts file to add the following two lines
127.0.0.1 ad-emea.doubleclick.net
127.0.0.1 rad.msn.com
Works a treat.
Code Snippets, Ideas and Rants from a Tech Lead interested primarily in server side web development and leading teams who build web apps.
Monday, February 24, 2014
Thursday, March 7, 2013
Log4j Default Settings
In Grails I find this the best log4j settings to use in my Config.groovy
log4j = {
debug 'grails.app'
appenders {
console name:'stdout', follow:true, layout:pattern(conversionPattern: '%d{HH:mm:ss} | [%-5p] | %c{2} | %m%n')
//rollingFile name:'mylog', file:'logs/eComm.log', maxFileSize:'10000KB', maxBackupIndex:10, layout:pattern(conversionPattern: '%d{dd-MMM-yyyy HH:mm:ss} | [%-5p] | %c{2} | %m%n')
}
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'grails.app.services.org.grails.plugin.resource',
'grails.app.taglib.org.grails.plugin.resource',
'grails.app.resourceMappers.org.grails.plugin.resource',
'net.sf.ehcache.hibernate'
warn 'org.mortbay.log'
}
Thursday, February 28, 2013
Technology Lead
Since taking on a new role as a technology lead in the digital marketing space I have had less and less to do with Grails and Groovy directly.
So I am going to branch out a bit on this blog to include all technology.
So I am going to branch out a bit on this blog to include all technology.
Monday, November 26, 2012
Grails dbconsole
A feature I have never used in Grails is the h2 web browser. A great way to see what the db structure and what the data looks like. This allows you to easily see the db structure your domain classes boil down to.
If you are running an application at
If you are running an application at
localhost:8080/appnameYou can browse to
localhost:8080/appname/dbconsoleFor the JDBC URL use the setting from your DataSource.groovy in my case
jdbc:h2:mem:devDbAnd there we go all domain objects visible. Not only can you run sql queries but you can insert, modify, delete.
Tuesday, November 6, 2012
Using ExpandoMetaClass in unit tests
There is great power in the ExpandoMetaClass, particularly when doing unit tests.
I want to unit test a specific Domain but it uses a service (in this case springSecurityService.encodePassword()) in one of its methods (protected void encodePassword). Rather than have an integration test or mock out the whole service I can just override a method on the fly. This allows me to just test the logic I am interested in.
The code in my test looks like this.
I want to unit test a specific Domain but it uses a service (in this case springSecurityService.encodePassword()) in one of its methods (protected void encodePassword). Rather than have an integration test or mock out the whole service I can just override a method on the fly. This allows me to just test the logic I am interested in.
The code in my test looks like this.
void setUp() {What I have done is overridden the method encodePassword on the class User.
println "setUp()"
User.metaClass.encodePassword = {->
password
}
def user = new User(username: 'user', enabled: true, password: '123').save(flush: true)
assert user
}
Domain event features
The Grails Domain class has some really nice event features in the afterUpdate, beforeUpdate.
What I wanted was if the domain.status was set to completed then domain.completedDate would be filled in with the current date. And if the domain.status was set to anything else, then domain.completedDate would be made null.
Was pretty easy to add this code to the domain
What I wanted was if the domain.status was set to completed then domain.completedDate would be filled in with the current date. And if the domain.status was set to anything else, then domain.completedDate would be made null.
Was pretty easy to add this code to the domain
def afterUpdate() {
if (status == Status.COMPLETED) {
if (completedDate)
completedDate = new Date()
} else {
completedDate = null
}
}
Subscribe to:
Posts (Atom)
