Thursday, May 23, 2019

What is SCSS?



SCSS is a preprocessor of css. It helps you write your css codes much easily.
It is developed on ruby on rails.


ever faced an issue in css where if you wish to change the complete color theme of website then you have to change each and every color properties of selectors? Or any such issues?

You can create variables in SCSS

$myColor: #333;

#myDiv1{
background-color: $myColor;
}
#myDiv2{
background-color: $myColor;
}


nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  li { display: inline-block; }

  a {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
  }
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav li {
  display: inline-block;
}

nav a {
  display: block;
  padding: 6px 12px;
  text-decoration: none;
}

Other features of SCSS are:

Partials and imports: Helps you to split your CSS into smaller, more maintainable portions.
Mixins: A mixin lets you make groups of CSS declarations that you want to reuse throughout your site.
Inheritance: let's you use the properties of any selector with another.
Operators: let's you do math in CSS easily.



References:
https://www.quora.com/What-is-SCSS-How-does-it-differ-from-CSS

Wednesday, May 22, 2019

How to override the default Origin header in Electron App?

Below is the code to do it.

import { app, BrowserWindow, ipcMain, session } from 'electron';

session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
    console.log('setting headers in main.dev.js details ', details)
    console.log('setting headers in main.dev.js callback ', callback)
    details.requestHeaders['Origin'] = 'https://origin.com';
    callback({ cancel: false, requestHeaders: details.requestHeaders });
  })


references:
https://github.com/electron/electron/issues/2245
https://github.com/electron/electron/issues/6859

Electron - Origin file:// header and heroku CORS proxy

Trying to avoid the Origin with file:// value, since the Axios and the XHR did not work, tried to use
CORS proxy, but this also did not seem to work!

References:
https://medium.com/netscape/hacking-it-out-when-cors-wont-let-you-be-great-35f6206cc646

Tuesday, May 21, 2019

How to Add interceptors to Axios

// Add a request interceptor
axios.interceptors.request.use(function (config) {
    const token = store.getState().session.token;
    config.headers.Authorization =  token;

    return config;
});


References:
https://stackoverflow.com/questions/43051291/attach-authorization-header-for-all-axios-requests?rq=1



Monday, May 20, 2019

What does the error mean "We apologize, the requested URL was rejected. Please consult with your administrator. Your support ID is:"


This happen when trying to hit the server URL for post from Electron application using XHR.
This is very strange although the GET request to the same is working.

So basically, below is the data from the app when using Electron and React-native as printed in the local node js server.
There is no much difference essentially.

From Electron App

 ------WebKitFormBoundaryuB0JC0S5inEZ8N9q
Content-Disposition: form-data; name="jsonData"

{"id":"","activeDuringCallHold":true,"activeDuringCallPark":true,"messageSourceSelection":"SYSTEM","audioFileDescription":null}
------WebKitFormBoundaryuB0JC0S5inEZ8N9q--


From React-Native app

POST
 --AtDN_wHVWYYY2U3o1qKMCiQ.jaTz2HCZ7tPArc_Iumu.6tU3-40e5n3KyyFK2-lW--VmQn
content-disposition: form-data; name="jsonData"

{"id":"","activeDuringCallHold":true,"activeDuringCallPark":true,"messageSourceSelection":"SYSTEM","audioFileDescription":null}
--AtDN_wHVWYYY2U3o1qKMCiQ.jaTz2HCZ7tPArc_Iumu.6tU3-40e5n3KyyFK2-lW--VmQn--


And the headers from the two platforms are like below. The main difference is Origin is set to file:// in Electron which is not able to be changed by setting the header options for some reason,

From Electron App

Headers

{"host":"127.0.0.1:3000","connection":"keep-alive","content-length":"266","authorization":"Basic bWNkLWFkbWluOkFkbWluMUAxMjM=","origin":"file://","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Electron/3.0.10 Safari/537.36","content-type":"multipart/form-data;","accept":"*/*","accept-encoding":"gzip, deflate","accept-language":"en-GB"}


 ------WebKitFormBoundaryuB0JC0S5inEZ8N9q
Content-Disposition: form-data; name="jsonData"

{"id":"","activeDuringCallHold":true,"activeDuringCallPark":true,"messageSourceSelection":"SYSTEM","audioFileDescription":null}
------WebKitFormBoundaryuB0JC0S5inEZ8N9q--


From React-Native app

Headers

{"host":"127.0.0.1:3000","content-type":"multipart/form-data; boundary=h3KnK7XfLMut.istQrUWQ7W7Ucw0uVer8cyQVaeOamrAHWqNVdVEf4-7ZEAesw.Nl8HRNm","user-agent":"BroadcloudBulkProvisioning/2 CFNetwork/975.0.3 Darwin/17.7.0","connection":"keep-alive","accept":"*/*","accept-language":"en-us","content-length":"330","accept-encoding":"gzip, deflate","authorization":"Basic bWNkLWFkbWluOkFkbWluMUAxMjM="}



POST
 --AtDN_wHVWYYY2U3o1qKMCiQ.jaTz2HCZ7tPArc_Iumu.6tU3-40e5n3KyyFK2-lW--VmQn
content-disposition: form-data; name="jsonData"

{"id":"","activeDuringCallHold":true,"activeDuringCallPark":true,"messageSourceSelection":"SYSTEM","audioFileDescription":null}
--AtDN_wHVWYYY2U3o1qKMCiQ.jaTz2HCZ7tPArc_Iumu.6tU3-40e5n3KyyFK2-lW--VmQn--


References:
https://support.mozilla.org/en-US/questions/1197304
https://support.mozilla.org/en-US/questions/1233607

Extracting Fingerprint from Google Play Console

Navigate to the Google Play Console and login
Choose the application you are signing
Go to Release Management –> App Signing
Copy /Download the SHA-1 certificate fingerprint from the App signing certificate section

This app signing certificate SHA-1, is the fingerprint of the final singing certificate that will be distributed via Google Play


references:
https://www.appdome.com/no-code-mobile-integration-knowledge-base/extracting-a-sha-1-fingerprint-from-the-google-play-app-signing-certificate/

React JS - Jargons Part 2

React Components: React components are JavaScript functions.

function Welcome(props) {
    return |h1>Hello {props.name}!|/h1>;
}
ReactDOM.render(|Welcome name="John Doe"/>, document.getElementById('root'));

React can also use ES6 classes to create components.

This example also creates a React component named "Welcome" with property arguments:

class Welcome extends React.Component {
    render() { return(|h1>Hello {this.props.name}|/h1>); }
}
ReactDOM.render(|Welcome name="John Doe"/>, document.getElementById('root'));


References:
https://www.w3schools.com/whatis/whatis_react.asp