englishteeth.co.uk

… the weblog of Ian “English Teeth” Robinson
  • rss
  • Home

Freesat

July 31, 2008 | 9:24 pm

Last week, I received a bunch of stuff I had ordered from SatCure. Cable, F-Plugs, silicon paste, that sort of thing. They provide a easy to use shopping list grouping the usual stuff together, rather than you having to trawl the site looking for what you’re after.

Yesterday though, my region 2 dish with quad LNB arrived. It was pretty straight forward to assemble. No instructions came with it, but they can be downloaded from here.

I wanted to have a play with my kit, but it was a work night, there was only an hour of light left and I was not really in a position or the mind set to embark on the full installation. I set the dish up on a camera tripod and pointed it in the general direction of the astra cluster.

Previously I had spent some time looking at Dish alignment with Dishpointer to get my compass bearing and elevation. This is a great resource if you’re planning an installation. Before looking at this, my assumed best location for my dish was way off. Completely the wrong side of our house!

I hooked up a satellite finder and an old sky digibox that hadn’t been used for five or more years. I didn’t really expect much of the box, but figured that it would at least power the satellite finder. Sure enough, even on my dish and tripod test rig, it was reasonably easy to fine tune the position.

Again fore reading resources such as Martin Pickering’s eBook and these sites helped:

  • http://www.satcure.co.uk/tech/satmeter.htm
  • http://www.uksatellitehelp.co.uk/
  • http://www.heyrick.co.uk/ricksworld/digibox/satfinder.html

The digibox didn’t lock at first. This would usually suggest that I was pointing at the wrong satellite, but I was more confident with the orientation than I was with the state of the box. Being a a software engineer faced with a hardware problem, I went through a couple of power down cycles; sure enough a few minutes later I had a lock, 50% signal strength (with meter still in-line) and 75% quality. A pretty pleasing result for no more than an hour of tinkering, and that’s an hour from unwrapping, and getting all the kit together. Lining up took no more than a few minutes.

This has definitely given me the confidence to proceed with the installation proper.

Comments
1 Comment »
Categories
miscellaneous
Tags
astra, digibox, freesat, satellite, tv
Comments rss Comments rss
Trackback Trackback

Autoboxing could catch you out

July 22, 2008 | 5:20 pm

A colleague pointed out an aspect of auto boxing in Java 5 that could catch you out. Which I have hopefully captured in the following contrived little unit test.

	@Test
	public void shouldTakeCareWithAutoBoxing() throws Exception {

		Map<String, Integer> myMap = new HashMap<String, Integer>();

		String letters = "Gotchas";
		Integer count = 0;

		myMap.put(letters, count);

		// count the letters
		for (int i = 0; i < letters.length(); i++) {
			count++;
		}

		assertSame(letters.length(), count);

		assertNotSame(letters.length(), myMap.get(letters));
		assertNotSame(count, myMap.get(letters));

	}

Auto boxing allows you to do seemingly convenient things, such as manipulate your Integer object like you would a primitive. However, Integers are immutable and what incrementing count is doing behind the scenes is referencing a new instance of an Integer with the updated value. Therefore count no longer references the object placed in the Map, that’s the old object…

Putting the each incremented value in the map would at least give you what you might be trying to achieve…

		// count the letters
		for (int i = 0; i < letters.length(); i++) {
			myMap.put(letters, ++count);
		}

		assertSame(letters.length(), count);
		assertSame(letters.length(), myMap.get(letters));
		assertSame(count, myMap.get(letters));

…but it’s not nice.

Following a quick google search I found Autoboxing Considered Harmful which provided an even more interesting aspect, which I have reproduced here as a simple JUnit test.

import org.junit.Test;
import static org.junit.Assert.*;

public class FurtherExperimentsInAutoBoxing {

	@Test
	public void twoObjectsWithTheSameValueShouldNotBeTheSame() throws Exception {

		Integer a1 = new Integer(150);
		Integer a2 = new Integer(150);

		assertNotSame(a1, a2);

	}

	@Test
	public void withAutoboxingTheyCanAppearToBe() throws Exception {

		Integer a1 = 100;
		Integer a2 = 100;

		assertSame(a1, a2);

	}

	@Test
	public void sometimesAnyway() throws Exception {

		Integer a1 = 150;
		Integer a2 = 150;

		assertNotSame(a1, a2);

	}

}

As the original author points out in his post, this is not the way you would want to write these, but for someone trying to grasp the concepts of what an object is and how to deal with them, these language features wouldn’t exactly help.

Comments
No Comments »
Categories
development
Tags
java, junit
Comments rss Comments rss
Trackback Trackback

Scoped Model Driven Interceptor

July 4, 2008 | 3:19 pm

In my struts 2 project, I have an action that implements the ScopedModelDriven interface.

I have configuration that references the ScopedModelDrivenInterceptor with a session scope…

	<interceptor name="scoped-model-driven" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
	     <param name="scope">session</param>
	</interceptor>

My action references this interceptor and specifies the key used when the object was previously put in the session.

	<interceptor-ref name="scoped-model-driven">
		<param name="name">session-key</param>
	</interceptor-ref>

This all works fine, except in my freemarker templates I now need to reference model.myproperty, rather than just property.

I could live with that, but unfortunately

	<#if myproperty?has_content>
		...

no longer returns any results and worse

	<#if model.myproperty?has_content>
		...

blows up completely!

javax.servlet.ServletException: ?size is unsupported for: freemarker.ext.beans.SimpleMethodModel
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)

I’ve tried a few variations of reference to no avail.

Very disappointing.
The reason I’m writing this up is that the scoped model driven thing looked almost exactly how I wanted to go with these actions, so I want to remember where I got to, but getting it working is more important.

Back to ModelDriven, SessionAware and Preparable…

Comments
2 Comments »
Categories
development
Tags
freemarker, java, struts2
Comments rss Comments rss
Trackback Trackback

Author

Ian Robinson is a relatively agile software engineer interested in things both sides of the object relational divide and beyond.

Categories

  • development (35)
  • miscellaneous (20)
  • music (7)
  • software (13)

Blogroll

  • Dan North
  • Dave Astels
  • Dave Wood
  • eirikso.com
  • Matt Raible
  • Object Mentor Blog
  • The Ancient Art of Programming
  • The Wisdom of Ganesh

Tags

active-mq architecture bauhaus blu-ray css db eclipse esb festivals freesat gorm grails groovy hd hd-dvd hibernate java jboss jms junit links mce media center mini music oracle osgi patterns pirsig plugins satellite soa software spring sql struts2 testing themes tools tv web wordpress xml xpath xslt
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox