Tuesday, December 31, 2013

Six major PHP frameworks




Six major PHP frameworks:
1) Akelos
http://akelos.org
2) Cake
http://cakephp.org
3) CodeIgniter
http://codeigniter..com
4) Kohana
 http://kahanaphp.com
5) Symfony
http://symfony-project.org
6) Zend Framework
http:// framework.zend.com



Sunday, December 29, 2013

PHP, file and directory operation



fopen, fwrite, fread, fcolse, file_put_contents, file_get_contents,
change file line break to HTML line break: nl2br
example:
if($handle=fopen(test.txt','r')){
   $content=fread($handle);
    fclose($handle);
}
echo nl2br($content);

Get line by line fgets

if($handle=fopen(test.txt','r')){
     while(1feof($handle)(
          $content=fgets($handle);
       echo $content."<br />";
      }
fclose($handle);
}

filesize: file size
filemtime: modified time (change content)
filectime: changed time (change content or metadata such as chmod)
fileatime: last access time such as read  or change.

Example
echo strftime('%m/%d/%Y %H%M',  filemtime($filename))."<br />";
touch($filename): update file time.

Directory operation
get current working directory: getcwd
create a new directory: mkdir
Example
makdir('mydir','0777'); //note permission  may be overwritten by umask
makdir('mydir/dir1/dir2','0777',true);recursively create new directoy

change directory chdir
remove a directory: rmdir
is_dir: to check if it is a directory
opendir: open directory to get directory handler
readdir: to get each file in a directory
Example:
if($mydir=opendir('test')){
    while($filename=readdir($mydir))
        echo $filename.'<br />';
}

Close directory: closedir
scandir:  read all file names in the directory into an array
Example:
$file_array=scandir('test');
foreach($file_array as $filename) 
       echo $filename.'<br />';
To remove .  and .. in the array, we can add
if(stripos($filename, '.')>0) // i.e first occurrence of  '.' not the first position.

>> &raquo;

Friday, December 20, 2013

CSS, @import and @keyframes




To include CSS file "mystyle.css" in a CSS file, using
@import "mystyle.css";
or 
@import url("mystyle.css");


To create an animation in CSS, using @keyframes, example:
@keyframes mymove
{
from {top:0px;}
to {top:10px;}
}
/* Safari and Chrome */
@-webkit-keyframes mymove
{
from {top:0px;}
to {top:10px;}


load to external web -font
@font-face
Reference:
http://www.w3.org/TR/CSS/ 
CSS framework:
http://blueprintcss.org/

HTML5 and DOM animation



HTML5 animation used Canvas. Call raf,js
using requestAnimationFrame, For example
function loop() {
   requestAnimationFrame(loop);
}
DOM animation:
To change a position of an object
<div id="box"></div>
Js script
d= doucment.getElementById("box);
d.style.left = x + "px";
d.style.top = y + "py";

JavaScript 3d library
http://threejs.org/

CreateJS: A suite of Javascript libraries & tools for building rich, interactive experiences with HTML5.
http://www.createjs.com

Wednesday, December 18, 2013

Microsoft Internet Explorer testdrive and Several good course from lynda.com




Microsoft Internet Explorer testdrive
http://ie.microsoft.com/testdrive/ 
Several good course from lynda.com
1. Mobile Web Design & Development Fundamentals with Joe Marini
2. Web design fundamentals
3. HTML5
4. CSS Fundamentals with James Williamson
5. HTML5 for Flash Developers with Lee Brimelow
6. PHP
7. MySQL
8. Apache
 

Monday, December 16, 2013

Measurement webpage performance





To measure webpage performance, we can use window.performance.timing object.
To calculate loading time, we can use loadEventEnd - navigationStart under use window.performance.timing.
Example code
<script type='text/javascript'>
    function loadingtime() {
        if (!!window.performance) {
            // navigation time is loadEventEnd - navigationStart
            var timingData = window.performance.timing;
            document.querySelector("#loadtime").innerHTML = (timingData.loadEventEnd - timingData.navigationStart);
             }
        else {
            document.querySelector("#message").innerHTML = "<p>This browser does not support the <code>performance</code> object</p>";
        }
    }

    function init() {
        setTimeout(loadingtime, 500);
    }
    window.onload = init;
    </script>

<div id="message">
<p><span class="label">Load Time: </span><span id="loadtime"></span>ms</p>
</div>

Friday, December 13, 2013

Backup before Christmas shutdown




 1) Backup file repository and database of main and research projects to local and mirror site.
 2) Recursively (incremental)  backup local computer directories CAS and real-server to external drive (j)
I used Deltacopy\rsync.exe (download from Internet) to backup files in Windows 7 to external disk J.
type cmd in Windows search box in Start, under Windows prompt
C:\Deltacopy\rsync.exe  -v -rlt -z -p --chmod=ugo=rwX --delete   /cygdrive/c/Users/jiansen/desktop/CAS/  /cygdrive/j/jiansen-office/CAS/
C:\Deltacopy\rsync.exe  -v -rlt -z -p --chmod=ugo=rwX --delete   /cygdrive/c/Users/jiansen/desktop/real-server/  /cygdrive/j/jiansen-office/real-server/
C:\Deltacopy\rsync.exe  -v -rlt -z -p --chmod=ugo=rwX --delete   "/cygdrive/c/Users/jiansen/Google Drive/"  /cygdrive/j/jiansen-office/GoogleDrive/ 

Access to online remote desktop application fail



Install Citrix receiver for Windows.

Tuesday, December 10, 2013

Reviewer Subject Assignments bug in research portal




Reviewer Subject Assignments work fine in original website, but failed in mirror site.
Reviewer assignment not saved in project NASA QCPR 2.
http://dev.cesei.org:8080/research/projects/manage_review_assignments.php
modify C:\php\php.ini in dev.cesei.org
line 384 change
max_execution_time = 30
to
max_execution_time = 300
line 405 change
memory_limit = 128M
to
memory_limit = 256M

line 801 change
upload_max_filesize = 2M
to
upload_max_filesize = 100M

line 805 add
upload_tmp_dir ="C:\LMS\file_uploads"


apache, cannot delete error.log
C:\Program Files\Apache Software Foundation\Apache2.4\logs
around 30G
stop Apache server first, dete error.log, then restart server

Still not fix the problem, check
C:\Program Files\Apache Software Foundation\Apache2.4\logs\error.log
error message:
Tue Dec 10 13:39:20.820054 2013] [:error] [pid 248:tid 1116] [client 142.103.72.45:59138] PHP Warning:  Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0, referer: http://dev.cesei.org:8080/research/projects/manage_review_assignments.php

php.ini, line 401 change
 ; max_input_vars = 1000
to
 max_input_vars = 100000



Friday, December 6, 2013

Merge items for review and survey tabs in MY Survey in research projects




Items for review and survey side by side, not in different tabs, and  move the question by scrolling. File
C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\research\projects\review_survey.php
Modify
C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\_templates\rp_review_survey.tmpl.php
line 29  change
<div class="row">Please refer to the tabs below and to the right to view the <?php echo($asset_string); ?> and applicable survey.</div>
to
<div class="row">Please refer to below to view the <?php echo($asset_string); ?> and applicable survey.</div>
Remove line 38-39
   <div id="project-survey" onclick="set_mod_filter('survey');">Survey</div>
   <div id="project-asset" onclick="set_mod_filter('asset');"><?php echo( ucwords($asset_string)); ?></div>

line 41 change
<div id="project-group-asset" style="display:none;">
to
<div id="project-group-asset" style="display:block; width:48%;  overflow:auto;float: left;" >
<h2><?php echo( ucwords($asset_string)); ?></h2>

line 67 change
<div id="project-group-survey" style="display:none;">
to
<div id="project-group-survey" style="display:block; width:48%; height: 800px; overflow:auto; float: right;" >
<h2>Survey</h2> <br />



In Canhealth, still keep 60% and 35%.

Under my survey, remove, video link
 http://dev.cesei.org:8080/research/projects/view_project.php?pid=48
rp_view_project.tmpl.php
rp_reviewer_details.tmpl.php
line 115 change
  echo('<a href="'.$asset_props['link'].'" class="review-item">'.$asset_props['file_name'].'</a>');
to
   echo($asset_props['file_name']);

Wednesday, December 4, 2013

Meta tags for mobile site and more concepts and references for mobile application




These three meta tags tell the mobile browser to display the webpage as in mobile screen size, not desktop.
<meta name="HandheldFriendly" content="true" />
<meta name="MobileOptimized" content="320" />
<meta name="Viewport" content="width=device-width" />

  For Windows Phone, iPhone, Android, Opera, they have different default width values. Windows Phone 7: 1024 pixels, iPhone: 980, Android and Mobile Opera: 800 px (note 100px=2.646cm)
for "Zoom out" size instead of its real size. Using "width=device-width"  to force display in actual device width. For example:iphone resolution: 640 x 960 px, actual device-width and height: 320 x 480.
reference:
http://www.javascriptkit.com/dhtmltutors/cssmediaqueries2.shtml
http://www.javascriptkit.com/dhtmltutors/cssmediaqueries3.shtml
User agent switcher  0.7.3 add-on for Firefox. I only see iphone 3.0. We can add android and iphone 5 by click edit button. User agent strings can be found
http://www.useragentstring.com/pages/useragentstring.php
 webkit used by Apple's Safari web browser and Google's Chrome web browser versions up to 27,
  Trident engine used by Internet Explorer, and the Gecko engine used by Firefox.

CSS media queries:
In CSS:
@media screen and (max-width:800px) {

}
@media screen and (min-width: 801px) {

}
modernizr is a JavaScript library to detect  CSS3 and HTML5 features in user browser.
http://modernizr.com/
To use   modernizr JavaScript librar:
<script src="modernizr-1.7.js" type="text/javascript"></script>
test for geolocation  feauter
Modernizr.geolocation  will return true or false.
test for touch feauture
Modernizr.touch
Test for HTML5 feature
Modernizr.svg
Modernizr.canvas

Tuesday, December 3, 2013

Click link to call in mobile browser




 To callin mobile phone via clicking a link, the following syntac is used:
<a href="tel:+1800666666">Call us free!</a>
More about this:
http://www.mobilexweb.com/blog/click-to-call-links-mobile-browsers

Monday, December 2, 2013

mobione swipe and alternatives




Mobione iphone image swipe slider tutorial
https://www.youtube.com/watch?v=dsb4TDWjwlc
mobione alternatives:
http://alternativeto.net/software/mobione/
try  Appcelerator Titanium
Open Source by Appcelerator Inc. |
Mac, Windows, Linux, Online
http://www.appcelerator.com/
 Install appcelerator Titanium Studio in Windows 7
C:\Users\jiansen\AppData\Local\Titanium Studio\
Run  Titanium Studio
error message
"failed to create java virtual machine"
Solution:
remove
--launcher.XXMaxPermSize 
256m 
from
C:\Users\jiansen\AppData\Local\Titanium Studio\TitaniumStudio.ini line 5

Some other software:
skitch
http://evernote.com/skitch/ 

 swipe
http://stackoverflow.com/questions/5200497/sliding-and-swiping-through-pages-with-javascript-on-ipad

phonegap
https://build.phonegap.com/apps 

https://developer.apple.com/