Access Iphone file in arch linux computer

First install following packages

sudo pacman -Sy ifuse usbmuxd libplist libimobiledevice

Then reboot the system

Then make directory a to mount the files

mkdir ~/iPhone

Use the ifuse to mount the Iphone

ifuse ~/iPhone

If you want to mount specific application folder , run following command to identify the mount details

ideviceinstaller -l

If I want to mount Browser app folder , I have to run following

ifuse --documents com.eilvera.idwl ~/Browser/

How to write a post-receive script for bit bucket

The post script is useful when execute or trigger any action after pushing the code in repository

Following example shows how to push the code to s3 bucket after pushing the code.

#!/bin/bash
set -x #echo on

tag_push_trigger()
{    
    masterTag=$(git for-each-ref | grep $newrev | grep refs/heads/master )
    
    if [[ -z "$masterTag" ]]; then
      echo " Tag is not created for master branch "       
    else
      tag_create_zipfile  
    fi
}


tag_create_zipfile()
{
    export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxx
    export...

Magento 2 : How to use Javascript in Magento

Javascript in Magento 2

Magento 2 uses Require JS lib and Knockout JS lib to solve the page speed and manage the JS dependency.

As JS are loaded asynchronously in backend, it helps to increase the page speed.

The JS files can be found in following locations :

lib/web
view/area/web
theme/module/web
theme/web

Magento 2 uses requirejs-config.js in module view/area/ folder to map the JS file with alias.

Magento 2 declares JS using following ways :

data-mage-init
<script type="text/x-magento-init"> ...........

Magento 2 Tips : How to get client ip

The client ip can be retrieved using

getClientIp()

method in

Magento\Framework\HTTP\PhpEnvironment\Request

class. This is very useful , when do the ip restriction in maintenance page development.

Docker Tips

Here you can learn about the docker basic and its commands

  1. How to execute the docker run command

The docker run command is used to get the specific docker image from registry and start and run the container of the image.
For this example, the alpine docker image is used as it is more light weight linux image.

docker run alpine:3.4 uptime

Here the apline is a public image and it will be pulled from registry and created the container and started the container and ran the 'uptime' and exit....

Docker Compose Network

This example shows that how the static ip can be assigned to container and how to add another container network to a container. This can be done only for version 2 compose.

version: '2'

services:
  app:
    image: busybox
    command: ping www.google.com
    networks:
      app_net:
        ipv4_address: 10.0.0.10
  webapp:
    image: busybox
    command: ping www.yahoo.com
    network_mode: service:app
        

networks:
  app_net:
    driver: bridge
    ipam:
      driver: default
      config:
      - subnet: 10.0.0.0/24
        g...

Magento 2 Tips : Conditionally Loading Javascript and css in layout xml

First create your conditions in the system.xml..

Second add your css and js in your local xml.

<reference name="head">
    <action method="addCss" ifconfig="my_config_section/advanced/load_css"><stylesheet>css/my_module/my_module.css</stylesheet></action>
    <action method="addItem" ifconfig="my_config_section/advanced/load_js"><type>skin_js</type><name>js/my_module/my_module.js</name></action>
</reference>

Changing magento template file / content on the fly

The template file or content of the magento page can be changed on the fly using observer.

For example, if you want to change the product listing in the category view , just write observer for render before event and remove the specific block and add new block or just replace the template file with new template file with new content.

    $categoryProductBlock->setChild('product_list',$specificBlock);

Use helper method in template file

    <reference name="breadcrumbs">
        <action method="setTemplate">
            <template helper="seo/getBreadcrumbsTemplate">
                <param>page/html/breadcrumbs.phtml</param>
            </template>
        </action>
    </reference>

Display Product Price without GST based on customer group

Following methods of the Config.php(app/code/core/Mage/Tax/Model) need to be changed as follows to display the product price excluding GST

public function getPriceDisplayType($store = null)
{
    $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    if (isset($groupId) && ($groupId == 2) &&
        ((int)$this->_getStoreConfig(self::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, $store)) == self::DISPLAY_TYPE_INCLUDING_TAX){
        return self::DISPLAY_TYPE_EXCLUDING_TAX;
    }

   ...

Getting Magento Category Paths for a specific product

public function getCategoryPath($sku)
    {
        $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
        
        $pathArray = array();
        $collection1 = $product->getCategoryCollection()
            ->setStoreId(Mage::app()->getStore()->getId())
            ->addAttributeToSelect('path')
            ->addAttributeToSelect('is_active');
            

        foreach($collection1 as $cat1){            
            $pathIds = explode('/', $cat1->getPath()); ...

Executing remote script via ant

Following ant build script to help you to execute command in remote server.

<?xml version="1.0"?>
    <project basedir="." default = "build">
        <target name="build" description="Running test" >
            <path id="jsch.class.path">    
                <pathelement location="/usr/share/ant/lib/ant-jsch-1.9.2.jar" />
                <pathelement location="/usr/share/ant/lib/jsch-0.1.51.jar" />
            </path>
            <taskdef name="scp" classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp"...

PHP Composer

It is really useful to install the required library specific to the php project.

Following simple command help you to install it in your linux env.

curl -s https://getcomposer.org/installer | php

sudo mv composer.phar /usr/local/bin/composer

Not only you can get the lib but also you can publish your lib.

In following site you can check the available package.
Packagist.

In windows, It can be installed simply download and run the following exe file and It will be set in the PATH as well.
[Composer e...

Linux Help

How to show line number in vi editor
: Run

:set nu

How to show line number in gedit
: 1)Click on Edit menu
2)Select the Preference

3)Tick the Display line numbers

How to clear the screen

: ctrl + l

How to check the IP

: ifconfig

How to check the running process

: ps aux | grep redis

How to add users

  1. Open the terminal application.
  2. Login to Ubuntu server using ssh.
  3. Add a new user named foo to www-data group by running
 useradd -g www-data foo

com...