Wednesday 24 December 2014

daily software engineering diary


  1. how to see ajax requests from chrome 
    • you can press f12 and then in network see all the request till now as well as response and status.
  2. jquery check if anyone of radio button is selected
    • $("input[name='questionoption']").is(':checked')
  3. javascript array to string
  • array.join() 
  1. javascript string to array
    • string.split(",")
  2. mysql how to copy database without importing/exporting manually.
  • mysqldump -uroot -predhat automata_new_staging | mysql -uroot -predhat automata_new_dev

  1. flip the keys and values of array in php
  2. array_flip() 
merging of two array in php

  • array_merge(arr1,arr2) it will re-index all the key of arr2
  • http://php.net/manual/en/function.array-merge.php
  • but doing arr1+arr2 will not reindex key of arr2
if you are using submodule in project then you should not do development in that submodule in place.
because it might be the case that you forgot to push the change in remote repository but it's working fine in system and when you take pull then you have to redo changes if that repo is deleted!




if you use mysql alter modify then it will delete all other information . you have to provide details regarding that!

innodb

dump all the database using mysqldump
 mysqldump -uroot -predhat --all-databases  --skip-lock-tables > all_db.sql

create a softlink of directory on the root to get more space.
ln -s path dirname
don't forget to change the owner to root so that it will not give access denied error in the future.


Why can't PHP create a directory with 777 permissions?

the following link is very useful to understand this situation.
http://stackoverflow.com/questions/3997641/why-cant-php-create-a-directory-with-777-permissions


have you wondered why you were not able to create directory with permission 777 even after doing mkdir(path, 0777)?

that's because umask! it's mask/subtraction on permission of directory. so default value is 022. so when you give directory any permission xxx. ideally linux system will create directory with value xxx-umask in this case it would be 0755.


so you can set umask before creating directory using php 
http://php.net/manual/en/function.umask.php


How to exec a process in background and not waiting it for completion

You could use proc_open for this:

proc_close(proc_open ("./script.php &", array(), $foo));

The empty array for the output specs prevents opening any pipes to the new
process, so proc_open doesn't wait for the execution of script.php to
finish - the last parameter is just there because it has to be.
proc_close() closes the process immediately, so your PHP script doesn't



Difference between cp -r and cp -R

one of the difference I found that -r do not copy hidden directories while -R copies hidden directories.
I tested it .git directory in target directory and came to above conclusion. I am using currently centOS.
I may be wrong but it's open to discussion.

No comments:

Post a Comment