Wednesday, April 18, 2012

A hobby paying its own expenses.


I have 2 hobbies: programming and bicycles. I don't make money on bicycling, but programming on the other hand...

Last year I developed a simple slot-machine-game for android, simulating an old norwegian slot-machine from the 80's. The application works ok until some memory leak crashes the application. The application comes in 2 versions: 1) ad-version, user clicks the ads and I get some pennies, 2) a pay version, I get a dollar or so per application.

With the bugs and all, the application was well recieved in Norway and has had 56K downloads of the ad-version, where 97% of the downloaders are norwegian according to the google-stats. The pay-version has 91 downloads.

In total I have recieved about 500usd from ad-clicks and about 100usd from selling the ad-free version. Not enough to quit my day-job and live happily ever after, but enough to buy some gadgets for bicycling and more programming. So here are my next investments:


  • ContourROAM action cam: 300 USD
  • Arduino UNO r3 + accessories : 100USD
  • Stuff I need for building a quadrocopter based on arduino 200USD (++?)
Looking good, now I only need dx.com to deliver the parts, assembly a quadrocopter and make the arduino board-control the beast.

Tuesday, April 3, 2012

Gradle + cobertura + sonar

At my current client we use gradle for building, so i thought I should give sonar+cobertura a go. Here is my config.
subprojects {
    apply plugin: 'java'
    apply plugin: 'sonar'

    // add support for the cobertura task 
    def coberturaPluginBase = 'https://raw.github.com/valkolovos/gradle_cobertura/master/ivy'
    apply from: "${coberturaPluginBase}/gradle_cobertura/gradle_cobertura/1.0-rc4/coberturainit.gradle"

    // configure sonar to pick up the cobertura test-reports
    sonar {
        project {
            coberturaReportPath = file('build/reports/cobertura/coverage.xml')
        }
    }
}
Now you can run cobertura and sonar with the command:
 # gradle cobertura sonarAnalyze

You do need a running instance of sonar to make use of this. Download it here and configure the plugin like this.

Sources:
Sonar-plugin(1.0-m08)
http://gradle.org/docs/current/userguide/sonar_plugin.html
Cobertura-plugin(1.0-rc4)
https://github.com/valkolovos/gradle_cobertura

Wednesday, October 19, 2011

Gradle remote debug for java

Type:
export GRADLE_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y"


Run your gradle commands as normal and hook up on port 4000 to remote debug your app.

E.g. ./gradlew jettyRun

Monday, June 6, 2011

Map library for gwt

I recently have been working with a hobby project where I want to show a map and create an overlay(path) on the map. I also want to change the overlay of the map in runtime. To do this I´ve discovered these options, but only found one of them to be working for my purposes:

The Official Google gwt-google-apis maps version

the good
  • It works
  • Its the official thing, meaning that most of the functionality in google maps is supported
  • probably works on any version of the gwt
the bad
  • Its version 1.1 of the maps api, the latest version is 3. So you get an old look and feel on the map
  • You need an api key
  • Displaying several maps at once seems to be a problem

gwt-google-maps-v3

the good
  • works very well
  • version 3
the bad:
  • not official, not everything works
  • DOES NOT WORK ON LATEST GWT version!!!
the good
  • simple to use
  • version 3
  • works on any known gwt version
the bad
  • advanced functionality is not implemented yet

For me, the winner is gwt-maps3. It has the features I need(markers, polygon, polyline etc) and it works with the latest gwt version.

Friday, May 6, 2011

Mocking jndi for junit tests

SimpleNamingContextBuilder was the perfect match for me when i wanted to mock some jndi-references for my appctx in my junit-tests

@BeforeClass
    public static void mockJndi() throws IllegalStateException, NamingException {
        SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
        builder.bind("java.naming.factory.initial", new org.jnp.interfaces.NamingContextFactory());
        builder.bind("ConnectionFactory", new QueueConnectionFactoryBean());
        builder.bind("queue/someFileQueue", new ActiveMQQueue());
        builder.activate();
    }.

Thanks to http://formatmysourcecode.blogspot.com/ :)

Monday, February 14, 2011

HttpMediaTypeNotAcceptableException

Using spring mvc and the @ResponseBody annotation might give you the HttpMediaTypeNotAcceptableException if you set the "Accept" header to "application/json". To solve this, add jackson-jaxrs to your classpath.  Nothing else needs to be done, spring does it's magic.

In your test , slap on a @Autowired on your AnnotationMethodHandlerAdapter.

Sunday, February 13, 2011

Maven + appengine

This memo is about using maven with your google appengine project.

Prerequisites:
Maven 3.0x
Command line interface
Know how to edit your pom

Howto:
  1. mvn archetype:generate choose gae-jsp and enter your project group/artifactid
  2. cd
  3. edit your pom.xml file to define at least the 1.4.2 version of google appengine, found under the properties tag. 1.4.2
  4. type mvn install to check that everything is ok
  5. type mvn gae:unpack to download and install the gae runtime into your local repository
  6. Edit the src/main/webapp/index.jsp, remove all jsp tags.
  7. type mvn gae:run and open localhost:8080
Congrats, you are now ready to start your GAE project with maven. I suggest
  1. mvn eclipse:eclipse and import the project into eclipse.
  2. Add spring, spring-mvc and spring-jdo or spring-jpa to your projects pom-file.

Update: updated version from 1.4.0 to 1.4.2