Filter On Object in javascript


let {tabsData} = this.state;
        for (let element in tabsData) {
            if(tabsData[element].key == cat_name) {
                this.setState({
                    defCatSelected : cat_name,
                    filtersData : tabsData[element].filter
                })
            }
        };

AWS : Change Time Zone.

date
Wed Jan 4 22:07:58 TLT 2012
You have new mail in /var/spool/mail/root

# mv /etc/localtime /etc/localtime.bak
# ln -s /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
# date

Extract Files

Type tar -xvf yourfile.tar to extract the file to the current directory.

Download Image in React From URL locally

function downloadImageFromURL(imageUrl) {
  if(imageUrl != null) {
      let imageData = imageUrl.split('/');
      let tempCount = imageData.length;
      let imageName = imageData[tempCount-1];
     
      axios({
        url: imageUrl,
        method: 'GET',
        responseType: 'blob',
      }).then((response) => {
        const url = window.URL.createObjectURL(new Blob([response.data]));
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', imageName);
        document.body.appendChild(link);
        link.click();
      });
  }
}

React ternary operator



var isLoggedIn = false;
var domain = 'pt';
var passwordLogin = false;
var b = false;
var c = false;



let message = (isLoggedIn === true && domain != 'pt') ? <Component {...props} /> :
  (isLoggedIn === true && config.domain == 'pt' && passwordLogin === true) ? <Component {...props} /> :
  (isLoggedIn === true && config.domain == 'pt' && passwordLogin == false) ? <Redirect to={{ pathname: '/newlogin' }} /> :
  (isLoggedIn === false && config.domain==='pt') ? window.location.replace('http://n.com/pt/360-vr?device=smart&offer=1') :
  <Redirect to={{ pathname: '/login' }} />

alert( message );


            

Laravel Join With AND/OR Condition.


Example Query.

Select * from abc_tbl 
inner join xyz_tbl on anb_tbl.id = xyz_tbl.userId AND anb_tbl.otherid = xyz_tbl.otherid

User Below Snippets.

$query_que = \DB::table('abc_tbl');

$query_que->join('xyz_tbl', function($join) {
            $join->on('abc_tbl.id', '=', 'xyz_tbl.userId');
            $join->on('anb_tbl.otherid', '=', 'xyz_tbl.otherid');
});