Sunday, 13 November 2011

Boot Camp Windows 7 (64-bit) on a Macbook Air (late 2010)

Installing Windows 7 (64-bit) on a Macbook Air (late 2010 model) via Boot Camp running Snow Leopard (10.6), I ran into porblems with the trackpad driver blue screening. Taking care with the installation process, I was able to avoid the problems.

Updating Boot Camp before Windows after the initial installation is complete is the key:
  1. Setup the partition using Boot Camp. I also use rEFIt to (a) allow installation from a USB drive, and (b) allow me to run Windows 8 in the last partition. You are only allowed 4 primary partitions, but there is a method to install Windows 7 without the extra 100MB partition it wants to create.
  2. Boot from the USB drive without any network connectivity and install Windows 7 as you normally would. If you have a network cable attached, after the installation is complete, you'll be in a race with the Windows 7 updater to install the Boot Camp update first. If you're using wifi, it's easy, just don't put your password in until Boot Camp is all up-to-date.
  3. Install the original Boot Camp WindowsSupport program, and reboot as requested.
  4. Check Windows 7 automatic updating is set to "manual", and enable your network connection.
  5. Run the Apple Software Update program and install the Boot Camp 3.2 update, and reboot as requested.
  6. Run the Apple Software Update program and install the Boot Camp 3.3 update, and reboot as requested.
  7. Install the Windows 7 SP1.
  8. Install the Windows 7 updates from Microsoft.
The same process worked for me in the Windows 8 Developer Preview installation.

Friday, 9 September 2011

Maven and Oracle's JDBC driver

Due to licensing restrictions, the Oracle JDBC driver jar will not be in the repository. The 
pom is there, and it's useful to add that to the conguration:

<dependency>
	<groupId>com.oracle</groupId>
	<artifactId>ojdbc14</artifactId>
	<version>10.2.0.4.0</version>
</dependency>

After that is done, you will then see an error message from mvn about "Could not find artifact com.oracle:ojdbc14:jar:10.2.0.4.0 ...". To resolve that, you need to manually add the JDBC driver jar file to your local .m2 repostiory:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
-Dversion=10.2.0.4.0 -Dpackaging=jar -Dfile=/path/to/ojdbc14.jar


PS: The ojdbc14.jar file will be on your database server in the ${ORACLE_HOME}/jdbc/lib/ directory.

Maven and Hibernate and Unit Tests (example using the JDK logger)

While attempting to run some unit tests that rely on the H2 in-memory database, I saw this failure:
...
Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
	at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
	at org.hibernate.cfg.Configuration.(Configuration.java:165)
	[snip]
	... 74 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 82 more

The maven dependency:tree target shows:
[INFO] +- org.hibernate:hibernate-core:jar:3.5.0-Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.5.8:compile

The org.slf4j:slf4j-api.jar provides the interface, but not a logging implementation. To add the JDK logger implementation, and additional dependency is required:
<dependency>
	<groupid>org.slf4j</groupid>
	<artifactid>slf4j-jdk14</artifactid>
	<version>1.5.8</version>
	<scope>test</scope>
</dependency>

(version 1.5.8 is required to match the api dependency in the hibernate 3.5.0-Final libraries.

Friday, 29 July 2011

Installing the Sun JDK on Ubuntu 11.04 (Natty)


sudo apt-add-repository "deb http://archive.canonical.com/ natty partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk


Shamelessly ripped off from http://www.ivan-site.com/2011/07/installing-sun-java-jre-on-ubuntu-11-04/

Tuesday, 10 May 2011

memcached-session-manager and Membase

The Tomcat memcached-session-manager and Membase do play well together, but the documentation on setting it up is a bit thin, and more focused on a memcached installation, especially if you are using Membase for the bucket replica and HA.


Membase
Set up the basic N-node Membase cluster. This part is trivial. You'll end up with N servers, all running their local Moxi proxy server on port 11211. You'll be able to telnet into any of the servers on that port and set an object. Telnet to another of the servers on port 11211 and you can get the object back out.


memcached-session-manager
The tricky part is that memcached-session-manager does not want to know about the topology of the replica data buckets in the Membase cluster. Leave that job to the Moxi memcached proxy. You get Moxi when you install Membase, or it's available as a separate installer for Linux.
Run moxi on each of your Tomcat hosts (do it for HA, though you will now need to monitor the moxi process as well as your tomcat process from the load balancer - if either dies, the server should be pulled from the pool). We use port 11311 for the moxi to separate it conceptually from the moxi's running in "gateway" mode on the Membase servers on port 11211:

/opt/moxi/bin/moxi -Z port_listen=11311 \
http://192.168.0.1:8091/pools/default/bucketsStreaming/default,\
http://192.168.0.2:8091/pools/default/bucketsStreaming/default


Then in your Tomcat <Context> configuration, you use the local moxi details in the session manager:

<Manager className="..." memcachedNodes="n1:localhost:11311" ... />


What you end up with is...

Tomcat1 -> LocalMoxi --\       
                        \      /--> Membase 1
Tomcat2 -> LocalMoxi ----\    /
                          >--<
Tomcat3 -> LocalMoxi ----/    \
                        /      \--> Membase 2
Tomcat4 -> LocalMoxi --/


And each local moxi is aware of the topology of the Membase cluster, and is aware of whcich Membase servers are running and which are down. You will still get errors in your Tomcat logs from the spymemcached library if you kill a Membase server. That will continue until you take a manual step of hitting "remove" on the dead server from the remaining server's console (and then you should rebalance the cluster).

Summary
It's possible this is overkill, but until we introduced the local moxi proxy processes, our Tomcat servers would not handle a Membase server being killed.

Wednesday, 30 March 2011

Firefox 4 - don't trim the URL preview

To stop Firefox 4 from trimming the URL in the preview and loading pop-ups, edit your <profile>/chrome/userChrome.css thus:
statuspanel {
max-width: 100% !important;
}
source: http://www.lifehacker.com.au/2011/03/stop-firefox-4-from-trimming-url-previews-in-the-status-bar/

Tuesday, 29 March 2011

Firefox 4 - make the app menu transparent

To change the "Firefox" app menu from orange to transparent in Firefox 4, edit your <profile>/chrome/userChrome.css thus:
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); 
#appmenu-button{
    background:transparent!important;
}
source: http://www.lifehacker.com.au/2011/03/from-the-tips-box-windows-7-favorites-the-firefox-button/

Saturday, 26 March 2011

ATV2 XBMC unofficial nightlies

ssh root@apple-tv.local
cd /private/var/tmp && \
wget 'http://hadm.net/~keith/xbmc_atv2/latest_atv2.deb' && \
dpkg -i latest_atv2.deb && \
rm latest_atv2.deb

Sunday, 20 March 2011

ATV2 xbmc.log file location

Apple TV 2 XBMC's xbmc.log file is located at:

/private/var/mobile/Library/Preferences/xbmc.log

Saturday, 19 March 2011

Showing a background image while an iframe is loading

Rather than a white rectangle on your page while an <iframe> is loading, you can set a background image in CSS. This works in IE7 & IE8 (with a bit of a flash when the iframe content is ready); Firefox 3.6 and Chrome 10 (perfectly); but in Safari 5 the background image is not shown until the iframe is loaded.

I found this useful when 'co-branding' a site to use another site's header and footer in an iframe. Since I could not trust the speed of the other sites, I grabbed their logo, then positioned it as a background image on the iframe so the logo was in the same position as the final iframe version. Then at least the user sees a nice logo straight away, and they might need a second or two before the navigation and other elements of the other sites headers show up.

This was the iframe code:
<iframe width="960" height="154" scrolling="no" frameborder="0"
marginwidth="0" marginheight="0" src="[other-site-URL]"
style="background:url('[local-logo-URL]') no-repeat scroll [X-off]px [Y-off]px;"></iframe>

Friday, 18 March 2011

iframe mysterious 3px margin

If you have some HTML like:

<iframe ...></iframe>
<div></div>

... you'll have a mysterious 3px gap between the elements even though everything says the margins are all zero. Rather than putting a margin-top="-3px" on the div, the better solution is to change the <iframe> to display:block.

Yup ... <iframe>'s default to display inline. Who would have guessed that!

Tuesday, 15 March 2011

Atlassian Bamboo running below normal as a service in Windows

To run the Atlassian Bamboo service in Windows at the "below normal" base priority, add this line to the conf/wrapper.conf file before installing the service:

wrapper.ntservice.process_priority=BELOW_NORMAL

Atlassian Bamboo as a service in Windows 64

If you try and run Atlassian Bamboo as a service on Window Vista 64 bit (and Windows 7 bit), you will get this in the bamboo.log:

INFO::jetty-7.2.1.v20101111
WARN::tmpdir
java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)

The workaround for Windows 7 (source: http://jira.atlassian.com/browse/BAM-8014 and http://confluence.atlassian.com/x/YYPcDQ) is to edit the conf/wrapper.conf file to add a java.io.tmpdir setting.

In Windows Vista, that does not work. Instead you need to change the service configuration to run as "this account" and enter a valid local user account. Then grant the "login as service" privilege to that account. Source: http://confluence.atlassian.com/display/BAMBOO/Running+Bamboo+service+on+Windows+as+the+local+user

Monday, 14 March 2011

Apple TV2, XBMC, disabling subtitles

When playing a video, press and hold the ok/enter button the remote to access the video playing "context" menu. From there, you can choose the audio option and disable subtitles.

Saturday, 12 March 2011

Apple TV2 Timezone fix for "wrong" time in XBMC

ssh into your ATV2, then:
cd /var/db/timezone
rm localtime
ln -s /usr/share/zoneinfo/Australia/Sydney localtime