Monday, 25 March 2013

unprotecting xlsm or xlsx files

I had to unprotect an xlsm spreadsheet (because the author is on vacation).

I found out how here:

I converted it into a crude bash script for in case I need to do it again:

workdir=`dirname $1`

filename=`readlink -f "$1"`
unprotected_filname=`echo $filename | sed s/.xlsm$//`-unprotected.xlsm
unzip "$filename" -d $tmpdir

sheetfiles=`find $tmpdir/xl/worksheets/ -iname "*.xml"`
echo $sheetfiles

echo "before replacing"
grep -c sheetProtection $sheetfiles
sed -i 's/]*\/>//g' $sheetfiles

echo "after replacing"
grep -c sheetProtection $sheetfiles

cd $tmpdir
zip -r "$unprotected_filname" *
cd -
rm -rf $tmpdir

Thursday, 7 March 2013

Set zoomlevels for gwt-openlayers and openstreetmap

I tried to make the zoom level bar show the same number of zoom levels as my offline cache and I'm shocked at how little information is out there about this.

The method below is doing the trick for me now:

     * @param options
     * @param minZoomLevel the minimum for this is 3 for open streetmap
     * @param maxZoomLevel
    private static void setZoomLevelRange(LayerOptions options,
        int minZoomLevel, int maxZoomLevel) {
        options.getJSObject().setProperty("zoomOffset", minZoomLevel);

        int len = maxZoomLevel - minZoomLevel + 1;
        double[] resolutions = new double[len];
        double curRes = 78271.51695 / (Math.pow(2, minZoomLevel - 1));
        for (int i = 0; i < len; i++) {
            resolutions[i] = curRes;
            curRes = curRes / 2;


// usage example:
        OSMOptions osmOptions = new OSMOptions();
        setZoomLevelRange(osmOptions, 5, 11);
        OSM baseTileLayer = new OSM("Mapnik", 
          // for offline tiles:
            + "tiles/${z}/${x}/${y}.png", 

The keys are:

  1. there is apparently a magic zoom level 1 resolution (I have not found how it is calculated).
  2. you can add higher and lower resolutions by multiplying or dividing them by 2.
  3. it is critical that you set the zoomOffset in accordance to what you use as your  minimum zoom level.

Your welcome and yeah you may copy the code as you want.


Monday, 4 March 2013

Get Lucky with JRebel

Get Lucky with JRebel
Win an all expense trip for 2 to Ireland

Hello Rebel,
Feeling lucky? We are offering an all expense paid trip for two to Ireland for St. Patricks Day 2014. Everyone who activates a JRebel trial in the month of March will be entered to win. So if you've never tried JRebel, or it's been a while since you've tried it, download your trial, put an end to redeploys, and get a chance to win a trip.

Activate your JRebel trial here

Just a few points to note:
  1. For this giveaway to become active we must reach 3000 JRebel trial activations.
  2. In order to enter you need to be a java developer or managing java developers
  3. You must provide complete and accurate contact info (we will be contacting the winner)
  4. Multiple sign-ups will result in you being disqualified
  5. Each person you get to activate a JRebel trial gives you an additional entry in the contest
  6. If you tweet @JRebel with a picture of your St. Patty’s Day celebration we will also throw your name in the hat to win 
Good Luck & Happy Coding!


Oliver White
Prize Guy

As the winner you will be free to pick which city you would like to visit for St Patrick's Day 2014 (Ireland or Boston - both known for their St. Patricks Day celebrations) If for whatever reason St. Patricks Day does not work as a travel date for you, then ZT agrees to discuss changing the dates, given the cost center stays the same The cost cap for this trip is $5000 USD
ZeroTurnaround, 545 Boylston, 4th floor, Boston MA 02116
Contact Us