ExtJs 5 & 'strict mode'

There are some good discussions on why one should or should not use the strict mode when coding in JS. I am not going to elaborate on that but rather focus on what to do to write an ExtJs class / app in strict mode.

Before going further, a bit of reading on the strict mode:

ExtJs implements its own class system and basically does not support strict mode (here, here). This is the case with ExtJs 5 too so far. But luckily it will not stop us from creating an ExtJs class with strict mode enabled.

So let's have a look at an ExtJs class with strict mode enabled class wide:

(function(){
    //Make sure strict mode is on
    'use strict';

    Ext.define('MyApp.Class1', {

        daNumber: null,

        constructor: function(config){
            //do some work
            this.daNumber = 666;
        },

        gimmeDaNumber: function(){
            return this.daNumber;
        }
    });
}());

So far so good, the class behaves as expected, so let's extend it:

More...

Batch resave CorelDRAW files to a lower version

A simple VBA script for batch dumping CorelDRAW files to a lower version.

Sub Resave()

    'remember to add a trailing '\', for example c:\my\path\
    Dim fld As String
    fld = "c:\my\path\"
    
    'make the out fld different than the main fld if needed
    'files are saved with a new name, so original ones will not be overwritten
    'remember to add a trailing '\', for example c:\my\path\
    Dim outFld As String
    outFld = "c:\my\path\out\"
    
    If Len(dir(outFld, vbDirectory)) = 0 Then
       MkDir outFld
    End If
    
    Dim file As String
    
    Dim sopts As StructSaveAsOptions
    Set sopts = CreateStructSaveAsOptions
    With sopts
        'looks like vba is happy to save down to v1...
        'x7 is not happy to reopen them though and the lowest version it is happy with is v12
        'in the gui the lowest save as version is 11 though
        .Version = cdrVersion12
        .Overwrite = True
        .EmbedVBAProject = True
        .Filter = cdrCDR
        .IncludeCMXData = False
        .Range = cdrAllPages
        .EmbedICCProfile = True
        .KeepAppearance = True
    End With
    
    file = dir(fld & "*.cdr")
    
    Do While file <> ""
        Dim doc As Document
        Set doc = OpenDocument(fld & file)
        doc.SaveAs outFld & Replace(file, ".cdr", "_v" & sopts.Version & ".cdr"), sopts
        doc.Close
        file = dir()
    Loop
    
End Sub

GlobalMapper - batch reproject and export geotif to ecw

A simple GlobalMapper script that iterates through all the tiff files in a specified directory, and exports them to ecw in EPSG 2180, 3857 and 4326.

//Exports all the tif files found in the source dir to ecw.
//Reprojects the data to 2180, 3857 and 4326 and the exports it to the appropriate folders

GLOBAL_MAPPER_SCRIPT VERSION=1.00

//Define in / out folders
DEFINE_VAR NAME=source_dir VALUE="C:\here\goes\input\path"
DEFINE_VAR NAME=target_dir VALUE="C:\here\goes\output\path"

//start the loop to iterate through all the files
DIR_LOOP_START DIRECTORY="%source_dir%" FILENAME_MASKS="*.tif" RECURSE_DIR=NO
	//Import the file
	IMPORT FILENAME="%FNAME_W_DIR%"
	
	//assign projection 4326
	LOAD_PROJECTION PROJ=4326
	EXPORT_RASTER FILENAME="%target_dir%\4326\%FNAME_WO_EXT%.ecw" TYPE=ECW BG_TRANSPARENT=YES FORCE_SQUARE_PIXELS=YES
		
	//assign projection 2180
	//Note: gm seems to not properly load 2180, so reading the proj def from a file
	LOAD_PROJECTION FILENAME="%source_dir%\2180.prj"
	EXPORT_RASTER FILENAME="%target_dir%\2180\%FNAME_WO_EXT%.ecw" TYPE=ECW BG_TRANSPARENT=YES FORCE_SQUARE_PIXELS=YES
	
	//assign projection 3857
	//Note: gm seems to not properly load neither 3857 not 900913, so reading the proj def from a file
	LOAD_PROJECTION FILENAME="%source_dir%\3857.prj"
	EXPORT_RASTER FILENAME="%target_dir%\3857\%FNAME_WO_EXT%.ecw" TYPE=ECW BG_TRANSPARENT=YES FORCE_SQUARE_PIXELS=YES
	
	//Unload the loaded data
	UNLOAD_ALL

// End the loop
DIR_LOOP_END

GDAL - assign a projection to a tif

per file:

gdalwarp -t_srs "EPSG:4326" input.tif output.tif

and a batch:

@echo off
mkdir processed
for %%F in (*.tif) do (
	echo processing %%F
	gdalwarp -t_srs "EPSG:4326" %%F processed\%%F
)
pause