Posts

How to config python3.6 interpreter in pycharm in ubuntu os

Image
How to config python3.6 interpreter in pycharm in ubuntu os Install pycharm education is free in ubuntu software store and after installing the pycharm to RUN the python file, we need to config python interpreter by pressing short cut ctrl + Alt  + s in keyword in pycharm will show configuration like screenshot below. pycharm python configuration Type interpreter in search box and select project interpreter  and select show all option in dropdown it will display pop up if you have configured then it will show configuration or it will show empty , if it as configured then select it  if it is not then click the plus + button ,which will give you option to select python version to select interpreter to run your project. select the python version and apply the changes ,then you will be able to run the pythpn file. Please share your comment below and any tips or tricks in python. Thank you

palindrome in python3.6 and php7

I am just practising, some interview question in both python and php to solve palindrome in easy way  to remember in interview.please share your solution or any latest interview question both php and python in comment box. PHP : $s =  'malayalam' ; $y =  '' ; for  ($i = strlen($s) -  1 ; $i >=  0 ; $i--) {     $y .= $s[$i]; } echo $y .  '</br>' ; if  ($s == $y) {     echo  "true" ; }  else  {     echo  "false" ; }

Increase the performance of yii2 project

Image
Increase the performance of yii2 project Recently, I was working on yii2 project with php 7.2 ,we were facing an issue on yii2 schema database ,in which we were using it yii2 as layer and was calling another yii2 API .At long run we were able to find that YII2 as some default rules in schema. Points: 1)  By default we are using active record ORM by YII2, So by default yii2 scans the database schema for every SQL query action. 2)To avoid it we used yii2 schema caching along with that ,we create CRON job to executes code from below link. https://forum.yiiframework.com/t/how-to-clear-schema-cache/35109/6 3) The CRON will refresh the schema of all tables and clear the cache. Please share your comments ,if there any other way to increase the performance of yii2. REFERAL: https://www.yiiframework.com/doc/guide/2.0/en/tutorial-performance-tuning#enable-schema-caching

yii2 arrayhelper::map vs array_map

Recently i was working on YII2 project in which i came across arrayhelper::map() and was thinking alternate in php. so i used array_map() also tested the performance of both in yii2 by start time and end time for both ,surprising was that execution time remain same.please let me know if there is any alternate that will execute faster then arrayhelper::map(). Adding the code in yii2: function find_field($value){ $value['id'] = $value['name']; return $value['id']; } $array = ['1'=>['id'=>1,'name' =>"pramodh",'address' =>'45 vk street','loc'=>'cbe'],'2'=>['id'=>2,'name' =>"pramodh kumar",'address' =>'45343 vk street','loc'=>'pune']]; $a = array_map(array($this,'find_field'),$array); print_r($a); yii2 code: $list = ArrayHelper::map($array,  ' id ' ,  

Add and find the rank in array using php

Hi  Recently i went to interview i was asked to add a mark and find the rank of it using php. 1) First i created a function called  rankChecker and passing  two parameter like collection of marks in array and mark that will be added and finding the rank of it. 2) Then i created dumpy variable $s ,$ab as array. 3)After that i added the mark in the array mark list and sorted into descending order and looped in for loop. 4) passing the value of first array into dumpy array $ab as key and passing the $i value  incremented by one as $i starts with zero. 5) And returning the current $ab array and passing $mark as key value in it. function rankChecker($arr,$mark){ $arr[] = $mark; rsort($arr); $ab = array(); //echo count($arr);    for($i=0;$i<count($arr);$i++){          $ab[$arr[$i]] = $i+1;       } return $ab[$mark]; } $arr=[39,37,34,56,67,23,37]; $mark=10; print_r(rankChecker($arr,$ mark));

print triangle of star using php

1) first loop considering $i as row and $j as column ,where total number of row is 4 and column is 7. 2) second is print * as passing the condition as following. CODE: for($i=1;$i<=4;$i++){     for($j=1;$j<=7;$j++){             if($i==1 && $j==4)             {                 echo "*";             } else if(($j==3 || $j==5)&& $i==2 )             {                 echo "*";             }else if(($j==2||$j==6)&&$i==3)             {                 echo "*";             } else if(($j==1||$j==7)&&$i==4){                 echo "*";             }             else{                 echo " ";             }     }     echo "\n";     }

find second highest value in array using php

1) First step is to sort the array in desc. 2) create two variable  like $fh as first highest and $sh as second highest. 3) loop the array in foreach ,we will check the if condition to first val is greater then $fh variable ,where first iteration first highest value will be assigned to $fh value. 4) second  else if condition will be same ,but here variable will be $sh and another condition in is check duplicate value of highest in the array. $arr = [55,40,50,76,76,40,30,20,60,89]; rsort($arr); $fh=0; $sh=0; foreach($arr as $val){     if($val > $fh){         $fh = $val;     } elseif(($val>$sh) && ($val != $fh)){         $sh = $val;     }   } echo $sh;