Monday, March 22, 2010

Pay As You Go PAYG Price Changes on three.co.uk : What is it with greedy telecoms companies?!

UPDATE:
I've decided to stay on three for the time being, however to subsidise their answerphone charges I and my finacĂ©e have now had to pay, I've switched my netbook to use an O2 SIM instead. Cost to me, nothing (I still pay O2 but have a larger download limit), cost to three.co.uk, £5-£10 a month.

Original post follows:
Basically I'm on Flat 12 tariff on the three network and a few minutes ago I texted new terms and conditions changes taking place from April 2nd.

Frankly I'm pissed off - here's the changes in summary (excluding international and special number price hikes):
  • Now charging 15p/min for voice mail/spam/skype spam that goes to your answer phone (this was free).
  • Trying to cut down their facebook bandwidth by offering facebook without pictures - text only - who does that really benefit three?
  • Free twitter - whoopie do. I don't twitter, but I bet three'll pull in some nice cross subsidy deal for this.
  • Telling me my calls to other mobile networks have gone up to 25p/min (I'm on flat 12, that's 12p for those idiots at three that can't count - I haven't changed my contract!)
  • Making out the existing unchanged free internet allowance and free texts are some great offers to make up for this price hike!!!
  • Tell me they are still better than their competitors (obviously running full damage control here - they know this'll be unpopular and cause people to leave). Orange used to say the same thing.
  • Hides the terms and conditions off their main website but sends you a link by phone to abbreviated stuff just meant to annoy.

Oh yes I can still get free Skype calls, but with all the recent outages, disconnects and failed logins I can't exactly rely on it - or is that the point?!

If this all goes through three can look forward to losing a large number of customers if they've got the nouse not to get fleeced by Three Telecom.

Sunday, March 21, 2010

How to Set or Increase the -Xmx Heap Memory of An Executable Java Jar

So a lot of people say that setting the -Xmx heap memory of an executable Java jar cannot be done, that it must be done on the command line or via batch script negating the double click functionality of a jar or Java Webstart.

Actually it can be achieved quite easily with a mostly cross platform compatible work around/solution (although this fix won't help you if you have a custom Java security policy - 99% of people don't ;))

The benefit of the solution below is that it doesn't rely on hard coded paths which will break cross platform compatibility:
  1. Create a small separate runner class with (another) main method in the jar. Set the main-class attribute of the jar to use this class.
  2. The new main method should check your conditions (e.g. you have enough memory).
  3. The new main method should start a new Java process without a hardcoded path for cross platform compatibility if the conditions are not met.
  4. Specify your parameters on the command line for that process (e.g -Xmx)
  5. Do NOT have the new main method use the "-jar" parameter as this does not work on all platforms due to path to jar issues (in fact it only seems to work on Windows).
Basically derive some code from the following example (taken from Image to ZX Spec 1.2). Note this fix uses a non standard option for MAXIMUM HEAP.

Note I am relaxing my usual GPL 2 licence for this Java class, if you derive from it consider it to be BSD licenced. I also ask you put a link or note in your software to my website in your licence/list of licences. The website you should use for reference is http://www.silentsoftware.co.uk

Taken from Image to ZX Spec 1.2.1, where the class "uk.co.silentsoftware.ui.ImageToZxSpec" is the real main class to start the application.

/* Image to ZX Spec
* Copyright (C) 2010 Silent Software (Benjamin Brown)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Silent Software, Silent Development, Benjamin
* Brown nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package uk.co.silentsoftware;

import uk.co.silentsoftware.ui.ImageToZxSpec;

/**
* Solution/workaround to allow executable jars
* to change their memory settings as Java cannot
* have its command line properties defined in a
* Jar file. Why Sun never implemented anything like
* this is beyond me.
*/
public class ImageToZxSpecRunner {

  /**
    * Bare minimum heap memory for starting app and allowing
    * for reasonable sized images (note deliberate 1 MB
    * smaller than 512 due to rounding/non accurate free
    * heap calculation). The solution allows JVMs with
    * enough heap already to just start without spawning
    * a new process.
    */
    private final static int MIN_HEAP = 511;

    public static void main(String[] args) throws Exception {

    // Do we have enough memory already (some VMs and later Java 6
    // revisions have bigger default heaps based on total machine memory)?
    float heapSizeMegs = (Runtime.getRuntime().maxMemory()/1024)/1024;

    // Yes so start
    if (heapSizeMegs > MIN_HEAP) {
      ImageToZxSpec.main(args);

    // No so set a large heap. Tut - I did use -server mode here originally
    // which does something similar for heap (i.e. can choose a machine specific
    // maximum) but this has some problems with Java 6 R19 for some reason
    // on my single core machine but worked on Java 6 R13 :( so for now I'll
    // use a naughty non standard -XX:+AggressiveHeap option.
    // NOTE I DO NOT RECOMMEND YOU DO THIS FOR PRODUCTION CODE use -Xmx1024m
    // instead (or whatever memory you need) as another constant and use this
    // in place of "-XX:AggressiveHeap" below. E.g.
    // "private final static int RECOMMENDED_HEAP = 1024;"
    // and
    // ...new ProcessBuilder("java","-Xmx"+RECOMMENDED_HEAP+"m"...
    } else {
      String pathToJar = ImageToZxSpecRunner.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
      ProcessBuilder pb = new ProcessBuilder("java","-XX:+AggressiveHeap", "-classpath", pathToJar, "uk.co.silentsoftware.ui.ImageToZxSpec");
      pb.start();
    }
  }
}

If you find this useful (or it's saved your bacon at work!) or want to post a more generic/improved version drop me a comment (and please remember to add the licence as described above or your code will break ;) )!

Friday, March 12, 2010

Image to ZX Spec 1.1 Released

Image to ZX Spec 1.1 is now freely available.
UPDATE: Get the latest 1.3.1 build

You can use Image to ZX Spec 1.1 online here (requires Java 6) or choose to download it.
Image to ZX Spec allows you to:

- Create retro art work, any size image can be "Spectrumized" (.png, .gif .jpg file) using
and one of 15(!) dithering modes (shading for the non techies).
- Convert JPEGS or GIFs to a ZX Spectrum slideshow (tap file).
- Convert JPEGS or GIFs to a ZX Spectrum SCREEN image (.scr file).
- Convert an entire directory of images, with previews.
- Choose from numerous processing options as to how the images will be converted.
- Change all processing options on-the-fly.



New for Version 1.1
- Added new Atrribute Favoritism feature to choose the colour set to use (greatly improves default image quality).
- Added Dither Preview feature which displays previews with different dithering algorithms (and takes advantage of multi core processors).
- Updated BASIC slideshow program with new warning to stop tape.
- Minor bug fixes to do with image conversion colour choice.
- Memory usage increased for larger image conversion (512MB min).
- Improved UI layout for Linux based systems (tested on Ubuntu)
- Main frame has splash picture, About box displays system info.

Requirements
Java 6 or better
Online version: >256MB memory free (image size limited).
Standalone version: >512MB memory free (larger image sizes permitted).

Downloads
Try Image to ZX Spec Online
Image to ZX Spec 1.1 Standalone
Image to ZX Spec 1.1 Source Code

Many thanks to Viperfang Networks for the hosting.

Tuesday, March 09, 2010

Image to ZX Spec 1.1 Progress

Just a quick update regarding Image to ZX Spec - multi core support has been added, dither preview is now included and Spectrum attribute favouritism option has been added greatly improving the image quality. Have a look at the preview image (click for full size image) - bear in mind these display like this on a real ZX Spectrum!