Skip to content

Strange ndk/jni error

This is largely a note for myself: Had an error where the jni code was segfaulting after it returned on android 4.0 but not previous versions, with an error like this: JNI ERROR (app bug): accessed stale weak global reference 0x2b (index 10 in a table of size 0)

Turned out to be that the method was defined as returning a byte[] array in the java code, but the c++ code was set to return a void. Somehow, this worked on previous versions!

Posted in Uncategorized.

Multiple screens with Vmware workstation

So, I wanted to allow a single host vm to use two screens. Doesn’t seem to be documented anywhere, but the cycle multiple screens option under the view menu works perfectly with a windows 7 host and and a ubuntu vm.

Hopefully this helps someone trying to Google to see if this is possible!

Posted in Computers, Linux.

RTL8168 under linux

Had some trouble with the network adapter in my new Gigabyte GA-Z68XP-UD3R motherboard under linux (Ubuntu 11.04) – it would stop working periodically and then start again, and the speeds were very slow – only around 300KB/s over my local network.

LSPCI output for the card is: 08:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06) . However, ubuntu was using the r8169 driver, rather than 8168.

This seems to have been resolved by downloading the drivers from here , unpacking, and then running the contained as root. This loaded the r8168 driver ,and the performance is now as you would expect and the dropouts seem to have gone away.

Couldn’t find much recent information on how to get this chipset running under linux, so thought I would post this information up.

Posted in Uncategorized.

Dojo/Dijit – Pages load blank in chrome, show on resize

I had a problem recently where my dijit layouts would sometimes load as a blank page in chrome – but they would show if the browser window was resized. The pages worked fine in firefox.

Someone on IRC pointed out the solution: Move all the style tags  to be a little way ahead of the script tags in <head> – apparently there is some race condition with chrome.

Hopefully this helps someone – Certainly wouldn’t have thought to try that!

Posted in Programming.

Dojo – Hiding disabled times for the TimeTextBox/TimePicker

I had an issue recently where I had a dojo time picker and wanted to restrict the available times.

The obvious solution was to set the constraints on the time text box with: <input id="from-time" name="from-time" /> , however this still allows you to scroll to the disabled times, you just cannot select them.

After some playing I came to this javascript code, which sets up a new time picker called my._TimePicker . This TimePicker just scrolls right from the upper allowed end to the lower end, and does not show the times in between.
The code is:

     // extend the default show() method
		_getFilteredNodes: function(/*number*/ start, /*number*/ maxNum, /*Boolean*/ before){
			// summary:
			//		Returns an array of nodes with the filter applied.  At most maxNum nodes
			//		will be returned - but fewer may be returned as well.  If the
			//		before parameter is set to true, then it will return the elements
			//		before the given index
			// tags:
			//		private
			var nodes = [], n, i = start, max = this._maxIncrement + Math.abs(i),
				chk = before?-1:1, dec = before?1:0, inc = before?0:1;
				i = i - dec;
				var date = new Date(this._refDate);
				var incrementDate = this._clickableIncrementDate;
				date.setHours(date.getHours() + incrementDate.getHours() * i,
					date.getMinutes() + incrementDate.getMinutes() * i,
					date.getSeconds() + incrementDate.getSeconds() * i);
				if(!this.isDisabledDate(date)) {
					n = this._createOption(i);
				i = i + inc;
			}while(nodes.length < maxNum && (i*chk) < max);
			if(before){ nodes.reverse(); }
			return nodes;


This is a bit messy since most of this code is duplicated from the _getFilteredNodes in dijit._TimePicker, with a little extra code taken from the _getOption method. But, it works!

This doesn’t affect every TimeTextBox on the page; to use it for a particular text box, use something like:

dojo.addOnLoad(function() {
	dijit.byId("from-time").popupClass = "my._TimePicker";

Hopefully this is useful for somebody!

Posted in Programming.

Rpn Calculator

This is a reverse polish notation (ie stack-based) calculator program written in ANSI C. It uses a dynamically allocated stack, so it can hold any amount of data in the stack up to the memory limits of the computer you are running on. It is currently using double-precision floating point operations although I might write a version using GMP (GNU multi-precision library) instead which will be much more accurate.


Posted in Programming.

Tagged with , , , .