Sunday, June 21, 2015

Set up a child account and set screen time limit in Windows 8

1) To set up a child account in Windows 8:
a) Click start menu and click control panel
b) Click User Account, click manage another account
c) Add a new account
d) Click add a child account with email or with email account
e) Click mange family safety online or directly go to your Microsoft account online

2)Set screen time limit for child account under parental control
a) Go to your microsoft account
b)click family and click screen time and select maximum time per day your child can use computer.
you can also choose which kind of websites, apps and games your child can access.
Video: Set up a child account and set screen time limit in Windows 8

Wednesday, June 10, 2015

MySQL data type timestamp auto-initialized and auto-updated

When we set MySQL data type timestamp, the default is auto-initialized. It is set to the current timestamp for inserted rows. This can be used in a column such as creation date. In PHPMyAdmin,
the attribute is empty.

When we set the attributes "on update current_timestamp" and type 'timestamp' in PHPMyAdmin,  the column is auto-updated. It is automatically updated to the current timestamp when the value of any other column in the row is changed from its current value. The column remains unchanged if all other columns are set to their current values. This can be used in a column such as modification date.

ALTER TABLE `max_term_default_ttr_lut` ADD `CreateDate` TIMESTAMP NULL DEFAULT NULL ,

Parse JSON in JavaScript

In PHP, I used
        $message['success'] = "Personal Information Updated";
        echo json_encode($message);

to pass $message to Javascript .post
    $.post('stakeholderInfo.php', $(".box#stakeholderInfo div #editInfoForm").serialize(), function(jsonMessage) {       
                            obj = JSON.parse(jsonMessage);

 Here I used JSON.parse to  parse JSON in JavaScript, then display message   alert(obj['success']);

Monday, June 8, 2015

phpexcel toggle expand and hide column in EXCEL and summary

 PHP has built-in feature to read and write CSV files. PHPExcel extends this feature and allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, Libre/OpenOffice Calc .ods, Gnumeric, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP.

PHPExcel can be downloaded from:

To start PHPExcel, PHPExcel library path should be included first, for example installed in _classes
                 include_once "./_classes/PHPExcel.php";
                include_once './_classes/PHPExcel/Writer/Excel2007.php';

                $objPHPExcel = new PHPExcel();

                //choose the first page
                $objSheet = $objPHPExcel->getActiveSheet();

Toggle expand and hide columns A to C default expand:
                foreach (range('A','C') as $column) {

Toggle expand and hide columns A to C default hide:
                foreach (range('A','C') as $column) {


Toggle expand and hide row 1

 Set autosize
                foreach (range('A','Z') as $column) {

Set font size
Set font bold
Set column A1 header  value
              $objSheet->SetCellValue('A1', 'faculty');
Set cell column 1 row 2 value '4'
   $objSheet->setCellValueByColumnAndRow(1, 2, '2');
Set number 1 as 0001 instead of 1
Set alignment left

Set column width
Set cell background color lightgreen
         'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => 'C3FDB8')

Set  line break using double quote to parse \n in PHP
    $objSheet->SetCellValue('N1', "Instr\n contact \n hrs");
Write out EXCEL file
            header("Pragma: public");
            header("Expires: 0");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Content-Type: application/force-download");
            header("Content-Type: application/octet-stream");
            //the folowing two lines make sure it is saved as a xls file
             header('Content-type: application/');
                //set the course offered id as page name
              $filename = " Export_".date("Ymd").".xls";
              header('Content-Disposition: attachment; filename= "'.$filename.'"');
             header("Content-Transfer-Encoding: binary");
              $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');