Thursday, 8 August 2013

python check if variable is empty

This is very easy to know in python that if any variable is empty or not

try to use :

if not ur_var:
     print "variable is empty 

get attention towards   not   keyword . This does all things .

This is equivalent to empty($ur_var)  in php

not keyword in python also checks for lists (array) , objects , strings , integrers , floats etc ..

example :

a= 0  or a = "" or a ={} or a= []
if not a :
    print "empty"

in all cases it will print empty .

Thursday, 23 May 2013

linux set ulimit

for setting ulimit u need to run following command

ulimit -n  10000  for setting limit to 10000

for soft files  
ulimit -Sn  10000

and for hard files
ulimit -Hn 10000


do it individually for all users

and this setting will be vanished after system restart

Saturday, 20 April 2013

virtual hosting in nginx

Virtual hosting in nginx is very simple :

see nginx.conf file 

one server block is generally available there .
see


server {
listen 80;
server_name _;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
   /root //html;
  index index.html index.htm index.php ;
}
}


this is default server setting. that means from all doamains this will work .

for virtual hosting define new server block 
 

:
server {
listen 80;
  server_name yourdomain.com;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
   /root /new_host;
  index index.html index.htm index.php ;
}
}





now settings have been changed

just restart nginx  and see
if traffic coming from  yourdomain.com  then it will point to /root/ new_host   directory .

else it will go to /root/html  directory and find related contents here.




thats it   . it was very simple



ask me if u want any further help .


Saturday, 13 April 2013

php call method froma string with parameters

very simple way to do that 


function abcd($parameter)
{
     return ture ;
}

$meth_str="abcd('ab')";
$res = false;
        $abc = '$res';
        $check = <<<bcd
if($meth_str)
{
        $abc= true;
} else
{
        $abc=false;
}
bcd;

        eval($check.";");    ///   that means $res=true;
     

Hope it helps
if need further help  comment here