Thursday, March 15, 2018

Update PHP version from 5.5.11 to 5.5.38 due to security in Windows Server 2012



In PHPMyAdmin, my PHP version is 5.5.11 and needs to update  to 5.5.38 due to security issue in Windows Server 2012
First stop IIS web services. In Windows Server 2012
 Administrative tool->Service
stop
World Wide Web Publishing Service

1. Open the Web PI application from the following location on your filesystem.
C:\Program Files\Microsoft\Web Platform Installer\WebPlatformInstaller.exe
2. Go to Products
3. Search PHP,
4. Click PHP 5.5.38. click Add
5. Click Install
6. restart

World Wide Web Publishing Service

Tuesday, February 13, 2018

Notepad++ - Add C++ compiler





 1) One way to add  C++ compiler  is to use Pocket C++.
Pocket C++ can be downloaded from:
https://github.com/dacap/pocketcpp
After installation, You can use F9 key to compile C++ files, and Ctrl+F9 to execute the compiled program.
Recently I found there is popup windows to block
me compile C++ code.
2) second way is to install g++ compiler separately and
integrate in Notepad++.

a) Install g++ using Cygwin (http://www.edparrish.net/common/cygwin.php)
or using MinGW (https://nuwen.net/mingw.html)

b) Open the Plugin Manager in Notepad++.

Plugins > Plugin Manger > Show Plugin Manager

c) Find the NppExec plugin in the list and install it.

    Check the box
    Press the Install button

d) Open the NppExec Execute dialog.

NppExec > Execute...

e) Copy and paste the following script into the Commands box.
(assume g++ installed in C:\cygwin\bin\g++.exe. If using MinGW, replacing with MinGW g++ directory)

SET G++ = C:\cygwin\bin\g++.exe
NPP_SAVE // save current file
cd $(CURRENT_DIRECTORY) // go to directory of the current file
"$(G++)" -Wall -Wextra -Wpedantic -std=c++11 -o "$(NAME_PART)" "$(FILE_NAME)"


f) Save the script with a name like: C++ compile.

    Press Save button
    Enter the script name
    Press the Save button
   
g)To only compile, press the keys Ctrl-6 together or use the following set of menu commands:

 To both compile and run a program, press the keys Ctrl-7 together or use the following set of menu commands:

    Follow the menu to the NppExec Execute dialog

    Plugins > NppExec > Execute

    Select C++ compile and run script from the dropdown list.
    Press the OK button.
   
References:
https://github.com/dacap/pocketcpp
https://nuwen.net/mingw.html
http://www.edparrish.net/common/cygwin.php
http://www.edparrish.net/common/npp4c.html
https://stackoverflow.com/questions/27980134/how-to-compile-execute-c-code-from-within-notepad
http://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/

Wednesday, March 29, 2017

Datatable export excel wraptext and newline



I have 14 column table id is tab1 under div class ajax_list, following code
is to solve Datatable export excel wraptext and newline

$(document).ready( function() {
var buttonCommon = {
  exportOptions: {
    format: {
      body: function(data, column, row) {
        data = data.replace(/<br\s*\/?>/ig, "\r\n");
        data = data.replace(/<.*?>/g, "");
        data = data.replace("&amp;", "&");
        data = data.replace("&nbsp;", "");
        data = data.replace("&nbsp;", "");
        return data;
      }
    }
  }
};
$.extend(true, $.fn.dataTable.defaults, {
  "lengthChange": false,
  "pageLength": 100,
  "orderClasses": false,
  "stripeClasses": [],
  dom: 'Bfrtip',
  buttons: [
    $.extend(true, {}, buttonCommon, {
      extend: 'excel',
      exportOptions: {
        columns: [0, 1, 2, 3, 4, 5,6,7,8,9,10,11,12,13]
      },
      customize: function(xlsx) {
        var sheet = xlsx.xl.worksheets['sheet1.xml'];
       
        $('row c[r^="A"]', sheet).attr( 's', '50' ); //<-- left aligned text
        $('row c[r^="B"]', sheet).attr( 's', '50' ); //<-- left aligned text
        $('row c[r^="C"]', sheet).attr( 's', '55' ); //<-- wrapped text
   //     $('row:first c', sheet).attr( 's', '32' );
        $('row c[r^="D"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="E"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="F"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="G"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="H"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="I"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="J"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="K"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="L"]', sheet).attr( 's', '55' ); //<-- wrapped text
        $('row c[r^="M"]', sheet).attr( 's', '55' ); //<-- wrapped text       
        $('row c[r^="N"]', sheet).attr( 's', '55' ); //<-- wrapped text       
      }
    })
  ]
});
      $("div.ajax_list").find('#tab1').DataTable({

                    paging: false,
                    fixedHeader: true
                } );

} );
Reference:
https://jsfiddle.net/lbriquet/0n9j52jx/

In some case, we need to update the cell and  need to reinitialize datatable.
To reinitialize datatable: (for table id is tab1)
              $('#tab1').DataTable( {
                     destroy: true,

                    paging: false,
                    fixedHeader: true
                } );


Monday, March 6, 2017

Powerful js library datable to export table in pdf, excel, sorting, freezing column and table header fixed (sticky)



Datable js library can be downloaded from
https://datatables.net/download/release

DataTables

DataTables is the core software of the DataTables project, and involves two primary files, the DataTables Javascript and CSS.

js:
https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js
css:
https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css

FixedHeader

The FixedHeader plug-in will freeze in place the header, footer and left and/or right most columns in a DataTable, ensuring that title information will remain always visible.
js:
https://cdn.datatables.net/fixedheader/3.1.2/js/dataTables.fixedHeader.min.js
css
https://cdn.datatables.net/fixedheader/3.1.2/css/fixedHeader.dataTables.min.css 

Example:

$('#myTable').DataTable( {
    fixedHeader: true
} );

FixedColumns

FixedColumns "freezes" in place the left most columns in a scrolling DataTable, to provide a guide to the end user (for example an index column).
js:
https://cdn.datatables.net/fixedcolumns/3.2.2/js/dataTables.fixedColumns.min.js 
css
https://cdn.datatables.net/fixedcolumns/3.2.2/css/fixedColumns.dataTables.min.css

Export pdf and excel

Example

$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    } );
} );
In addition to the above code, the following Javascript library files are loaded for use in this example:
 Reference:
https://datatables.net/extensions/buttons/examples/initialisation/export.html 

Sorting

https://datatables.net/examples/basic_init/table_sorting.html

Wednesday, November 30, 2016

Sweet Alert JS library - beautiful replacement of JavaScript Alert



You may think JS alert is boring and less flexible. You can use Sweet Alert. You can download and see the demo of sweet alert from:
http://t4t5.github.io/sweetalert/
Then initialize the plugin by referencing the necessary files (js and css):
<script src="sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="sweetalert.css">
Example 1: error message:
sweetAlert("Not Allowed", "Average of Chair's Recommended Step  exceeds 1.25!", "error"); 

result:
Example 2: error message:
                    sweetAlert({
                            title:" Are you sure?",
                            text:"You will not be able to edit.",
                            type:"warning",
                            showCancelButton:true,
                            confirmButtonClass: "btn-danger",
                            confirmButtonText: "Yes, Submit & Lock",
                            confirmButtonColor: "#DD6B55",
                            cancelButtonText: "Cancel",
                            closeOnConfirm: true,
                            closeOnCancel:true
                    },
                    function(response){
                            if(response == true){
                           
                            }else{
                                   
                            }
                    });


result: