Skip to main content

Posts

GIT :: Switch branch without discarding local changes

Sometimes you modified files in a branch and you need to switch current branch into different branch without committing them. You need to stash them first. $ git checkout develop error: Your local changes to the following files would be overwritten ... Run git stash save, or just plain git stash which is short for save $ git stash save Those are safely stored in the repository. After switch branch and you want will apply them. $ git checkout develop Switched to branch 'develop' $ git stash apply If it is successful you need to delete references to the commits.  $ git stash drop    But if you apply option does a merge stashed changes. $ git stash apply   There may be merge conflicts. All went successfully you can drop stash $ git stash drop git stash pop is short-hand for git stash apply && git stash drop

GIT Error: The following untracked working tree files would be overwritten by merge:

Recently I renamed following file names(changed only captal to simple) and added to branch(abc) and commited them. I pushed the branch as well.  app/SocialMedia/EmailShare.php --> app/SocialMedia/Emailshare.php         app/SocialMedia/EmailShareFactory.php ---> app/SocialMedia/EmailshareFactory.php After that I tried to checkout a different branch(beta). Accidently git throws following error. $ git checkout beta error: The following untracked working tree files would be overwritten by checkout:         app/SocialMedia/EmailShare.php         app/SocialMedia/EmailShareFactory.php Please move or remove them before you can switch branches. Aborting But when applying git status command no files to commit $ git status On branch abc nothing to commit, working directory clean Finally I checkout master branch. It was succefull. I think, because those files are still not in the master branch. After that I was able to checkout beta branch as well. Now that error happens again when I'm

Magento 2 : Less variable issue

If you get variable issue when running  grunt exec:themename  or when deploying theme using php bin/magento setup:static-content:deploy First delete var/*  Then run following commands php bin/magento setup:upgrade php bin/magento setup:static-content:deploy If doesn't solve your problem check your parent theme name in your theme.xml. If it is not luma then change back to luma and run following commands again. php bin/magento setup:upgrade php bin/magento setup:static-content:deploy

How to point Magento multi websites to domains

Backend configurations Add secure and unsecure domain urls for websites Add default domain url default config Index.php changes You need edit index.php file as follows switch($_SERVER['HTTP_HOST']) {     case ' domain.co.uk ':     case 'www. domain.co.uk ':         $mageRunCode = 'base';         $mageRunType = 'website';     break;     case ' domain.eu ':     case 'www. domain.eu ':         $mageRunCode = 'euwebsite';         $mageRunType = 'website';     break; } Comment following lines if you have /* Run store or run website */ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';   Point main domain by adding your hosting server dns in domain registrar                 It will take some time to resolve DNS settings. Use intodns.com to check dns of a domain.   Then you need to poin

How to retrieve data from another table while retrieving data from a table in loadFormData function in Joomla 2.5

I have to show data from two different tables. Therefore I had to change 'loadFormData' function to satisfy that. Current implementation was as follows. /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData()  { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_speakee.edit.batchofcard.data', array()); if (empty($data))  { $data = $this->getItem();                         }                          return $data; } Then I changed it to get data from another table called 'Discount' by calling table of 'Discount' and got table properties by primary key.  /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormDat

Convert date from one timezone to another timezone PHP

This example is from phone call history  //set default time zone date_default_timezone_set('America/New_York'); //Set call date and time $call_date = new DateTime(date("d-m-Y H:i:s", strtotime($call['calldate']." ".$call['calltime']))); //Create new time zone object $la_time = new DateTimeZone('Europe/London'); //Set time zone to date $call_date->setTimezone($la_time); //show new date and time echo $call_date->format('d-m-Y'); echo $call_date->format("H:i:s"); Chamath Gunasekara

Replace empty names with concatenated text in MySQL

There was a drop down which had a huge list of employees. But some of them hadn't name. It was empty. But not NULL in database.  Initial query was as follows.  SELECT emp_id, name from employees order by name asc But it shows empty options in select list first. Then I tried to replace name which was NULL using IFNULL function.  SELECT aemp_id, IFNULL(name, concat('Employee - ', emp_id)) as name from employees  where name="" order by name asc But it was failed due to empty values for name field. Then I checked for empty value for name field.              NULLIF(name, "") It will return NULL value if it is empty. Then I used  COALESCE function.It returns first NULL or NULL if there no-null values in the list. Complete query as follows. SELECT emp_id, COALESCE(NULLIF(name, ""), concat('Employee - ', emp_id)) as name from employees where name="" order by name asc enjoy. Chamath Gunasekara