Wednesday, January 28, 2015

Post large array in PHP




To post large array in PHP, we need to modify max_input_nesting_level and  max_input_vars inphp.ini, such as
max_input_nesting_level = 128

; How many GET/POST/COOKIE input variables may be accepted
 max_input_vars = 5000

Saturday, January 17, 2015

underscore (-) and dollars sign ($) in Javascript variables and functions





 underscore (-) and dollars sign ($) in Javascript variables are the same as other characters such as letters and number. For example _$.area is the as as other JS variables course123, c3 etc.

For dollars sign ($) in Javascript function may have special meaning, for example $() in jQuery represnets to call jQuery library. _() in Underscore.js call underscorelibrary.

Thursday, January 15, 2015

Latex: text wrap in multirow in tables





In latex, if we have a very long text in multirow in tables need to be wraped
   \multicolumn{1}{|l|}{\multirow{2}{*}{ Very long text Very long text Very long text}}  &
 We can add {\parbox{7cm}} as below, where 7cm is the text length begin to wrap
   \multicolumn{1}{|l|}{\multirow{2}{*}{\parbox{7cm}{Very long text Very long text Very long text }}}  &

Thursday, January 8, 2015

Reset PHPMyAdmin




To reset PHPMyAdmin in Linux:
  1. Stop the MySQL server
    sudo service mysql stop
  2. Start mysqld
    sudo mysqld --skip-grant-tables &
  3. Login to MySQL as root
    mysql -u root mysql
  4. Change MYSECRET with your new root password
    UPDATE user SET Password=PASSWORD('MYSECRET') WHERE User='root'; FLUSH PRIVILEGES; exit;
  5. Kill mysqld
    sudo pkill mysqld
  6. Start mysql
    sudo service mysql start
  7. Login to phpmyadmin as root with your new password

In Windows, for example my xampp installed in C:\xampp_php5.4\, PHPMyAdmin password is in
C:\xampp_php5.4\phpMyAdmin\config.inc.php

Wednesday, January 7, 2015

Import large sql file in XAMPP





There is a limitation to import a sql file in PHPMyAdmin, default around 2 MB. You can increase the limit by changing php.ini. But it still depends on memory limit.
For example, I have MySQL dump file around 100 MB.To import this huge file to database, first go to mysql.exe installation directory in command prompt (assuming xampp installed in C:\xampp_php5.4) :
cd  C:\xampp_php5.4\mysql\bin\
mysql -u root 
type following commands assuming tracs.sql is in C:/tracs.sql
mysql> create database tracs;
mysql> use tracs;
mysql> source C:/tracs.sql;

Sort PHP associate array by element value




For example, I have PHP associate array parents as following:
           $parents = array();
            $parents[]=array("tp_journal_id"=> "1000", "tp_parent_journal_id"=> NULL, "Code_Id"=> "2",
            "Rank_id"=> "0", "Stakeholder_Id"=>$instructor, "Tp_Categories_Id"=> NULL,
            "Courses_Offered_Has_Stakeholder_Id"=> NULL, "Courses_Offered_Id"=> NULL, "StartTerm"=>"1161",
            "EndTerm"=> "1161", "Transaction"=> NULL, "CourseReleaseValue"=> "0" ,
            "StudyLeaveValue"=>"1", "JournalEntries"=> "", "Status"=>"Active", "code_id"=>"2",
            "CodeAbb"=>"T", "Code"=>"Teaching", "Category"=> NULL, "tp_categories_id"=> NULL,
        "InstructorOverload"=> NULL, "sort"=>"1161" );
   
           $parents[] =array("tp_journal_id"=> "1000", "tp_parent_journal_id"=> NULL, "Code_Id"=> "1",
            "Rank_id"=> "0", "Stakeholder_Id"=>$instructor, "Tp_Categories_Id"=> NULL,
            "Courses_Offered_Has_Stakeholder_Id"=> NULL, "Courses_Offered_Id"=> NULL,       "StartTerm"=>"1154",
            "EndTerm"=> "1154", "Transaction"=> NULL, "CourseReleaseValue"=> "0" ,
            "StudyLeaveValue"=>"0", "JournalEntries"=> "", "Status"=>"Active", "code_id"=>"1",
            "CodeAbb"=>"R", "Code"=>"Research", "Category"=> NULL, "tp_categories_id"=> NULL,
        "InstructorOverload"=> NULL, "sort"=>"1154" );       


I want to sort array based on element StartTerm, PHP function usort can be used:
            usort($parents, function($a, $b) {
                return $a['StartTerm'] - $b['StartTerm'];
            });      
  

Tuesday, January 6, 2015

Using two CSS box shadow in one element





I have one CSS box shadow (inner line shadow red color in right side of inner box)
box-shadow: inset -10px 0 5px -5px hsla(0,100%,50%,0.5);
Another CSS box shadow (inner line shadow yellow in left side of inner box)
box-shadow: inset 10px 0 5px -5px hsla(30,40%,50%,1.5);
To combine these two shadows in one element, add comma and remove one of box-shadow:
 box-shadow: inset 10px 0 5px -5px hsla(30,40%,50%,1.5), inset -10px 0 5px -5px hsla(0,100%,50%,0.5);