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

React JS Jargons - Part 1

Babel: Babel is a JavaScript compiler that can translate markup or programming languages into JavaScript. With Babel, you can use the newest features of JavaScript (ES6 - ECMAScript 2015).
Babel is available for different conversions. React uses Babel to convert JSX into JavaScript.

JSX : JSX stands for JavaScript XML.JSX is an XML/HTML like extension to JavaScript. JSX is a XML syntax extension to JavaScript that also comes with the full power of ES6 (ECMAScript 2015).Just like HTML, JSX tags can have a tag names, attributes, and children. If an attribute is wrapped in curly braces, the value is a JavaScript expression.

React DOM Renderer:

The method ReactDom.render() is used to render (display) HTML elements:

|div id="id01">Hello World!|/div>

|script type="text/babel">
ReactDOM.render(
    |h1>Hello React!|/h1>,
    document.getElementById('id01'));
|/script>

JSX Expressions
Expressions can be used in JSX by wrapping them in curly {} braces.

|div id="id01">Hello World!|/div>

|script type="text/babel">
const name = 'John Doe';
ReactDOM.render(
    |h1>Hello {name}!|/h1>,
    document.getElementById('id01'));
|/script>

React Elements
React applications are usually built around a single HTML element. React developers often call this the root node (root element): 

|div id="root">|/div>

React elements look like this:

const element = |h1>Hello React!|/h1>

Elements are rendered (displayed) with the ReactDOM.render() method:

ReactDOM.render(element, document.getElementById('root'));

React elements are immutable. They cannot be changed.The only way to change a React element is to render a new element every time:

function tick() {
    const element = (

{new Date().toLocaleTimeString()}

);
    ReactDOM.render(element, document.getElementById('root'));
}
setInterval(tick, 1000);


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

Sunday, May 19, 2019

NGNIX how to specify SSL intermediate cert

The process of specifying intermediate certificate is same across server because it is really done on the crt file. Here is how to be done

First of all verify if there is any issue with the certificate chain by checking in the SSL checker.

https://www.sslshopper.com/ssl-checker.html#hostname=https://mysite.com

Now if the above test specifies that it does not work on certain platforms, we need to do the below to include the intermediate certificates.

https://scottlinux.com/2013/09/02/how-to-configure-ssl-certificate-chain-for-nginx/


$ cp example.com-2013.crt example.com-2013.pem
$ cat intermediate.crt >> example.com-2013.pem


Now that we got the certificate file that includes the chain, specify it is the SSL default file like mentioned in another post.

references:
https://scottlinux.com/2013/09/02/how-to-configure-ssl-certificate-chain-for-nginx/
https://www.sslshopper.com/ssl-checker.html#hostname=https://mysite.com

Saturday, May 18, 2019

How to generate a CSR on a NGNIX server

To generate a pair of private key and public Certificate Signing Request (CSR) for a webserver, "server", use the following command :

openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr

This creates a two files. The file myserver.key contains a private key; do not disclose this file to anyone. Carefully protect the private key.

In particular, be sure to backup the private key, as there is no means to recover it should it be lost. The private key is used as input in the command to generate a Certificate Signing Request (CSR).

You will now be asked to enter details to be entered into your CSR.

What you are about to enter is what is called a Distinguished Name or a DN.

For some fields there will be a default value, If you enter '.', the field will be left blank.

Country Name (2 letter code) [AU]: GB
State or Province Name (full name) [Some-State]: Yorks
Locality Name (eg, city) []: York
Organization Name (eg, company) [Internet Widgits Pty Ltd]: MyCompany Ltd
Organizational Unit Name (eg, section) []: IT
Common Name (eg, YOUR name) []: mysubdomain.mydomain.com
Email Address []:

Please enter the following 'extra' attributes to be sent with your certificate request

A challenge password []:
An optional company name []:


Use the name of the web-server as Common Name (CN). If the domain name (Common Name) is mydomain.com append the domain to the hostname (use the fully qualified domain name).

The fields email address, optional company name and challenge password can be left blank for a webserver certificate.

Your CSR will now have been created. Open the server.csr in a text editor and copy and paste the contents into the online enrollment form when requested.

Alternatively one may issue the following command to generate a CSR:

openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr -subj "/C=GB/ST=Yorks/L=York/O=MyCompany Ltd./OU=IT/CN=mysubdomain.mydomain.com"


references:
https://manage.bigrock.in/kb/answer/2394

Troublehooting echo in a VoIP call

When a caller or callee reports hear their own delayed audio being transmitted back to them, we refer to this as call audio echo. Echo is often caused by the hardware used, positioning and volume levels of the speaker and microphone at one end of the line, or by crosstalk on copper wire (landline) networks. This guide is intended to help diagnose and resolve call audio quality issues related to echo

Below are some of the common checks we can perform

Which side of the call is reporting the issue(s): caller, callee, or both?
Was the audio echoing the entire time, or did this occur at some point in the call?
Does this issue occur at the same time each call?
Are any parties using a speakerphone, or a separate microphone and speakers?
Does this issue only occur with specific phone numbers or number types (landline, mobile, VoIP, etc.)?
Does this issue only occur when calling or receiving calls from a specific region or country?
Do other callers/callees report similar issues?

Most audio echo issues are caused by one callee or caller's microphone picking up the audio coming from the speaker, and then transmitting it back through the call. Please run through this troubleshooting checklist to try and resolve this issue:

Disable any speakerphone functionality, and instead use a headset or a phone handset.
If using a computer with speakers and a separate microphone, use a headset or phone handset instead.
Lower the output volume on the speaker or handset.
If using a separate microphone, point it away from any speakers where call audio is outputting, and point it towards the caller or callee.


reference
https://support.twilio.com/hc/en-us/articles/360022008913-Troubleshooting-Call-Audio-Echo-Issues-Twilio-Programmable-Voice-Calls

Wednesday, May 1, 2019

How to get the status of Twilio services?

Twilios service status and external connectivity status with other systems can be found using the url below

https://status.twilio.com/

references:
https://status.twilio.com/

Twilio Virtual Phone number



A virtual phone number is a standard telephone number that is not locked down to a specific phone. A virtual number can route a voice call or text message to any phone or workflow. With virtual numbers powered by an API, complex software workflows can be built that are triggered by calls and texts.

With Twilio you can get instant access to local, national, mobile, and toll-free virtual numbers in 50+ countries.

Below are just a few of the ways virtual numbers can be used.

International Local Presence

Using a local number allows foreign business to have a local presence in multiple countries.

Due to the high cost of international long distance, customers are far more likely to dial a local number. Similarly, individuals with friends and family in other countries can use a TwimlBin to setup their virtual number with simple call forwarding. This allows their loved ones to call them on a local number.

Call tracking

Businesses use virtual phone numbers to track the effectiveness and conversion rates of marketing campaigns. By putting a unique phone number on each campaign (e.g. different search engine ads, billboards, or maganize ads) marketers can track which ad recieved the most calls.

Masked / Anonymous Calling

Marketplaces and on-demand services can use virtual phone numbers to anonymize interactions

Direct Inward Dialing

Businesses can give each employee their own phone number and route the call into their extension using Direct Inward Dialing (DID). DID allows callers to skip a queue or phone tree and ring directly through to the phone of the specific person they want to get in touch with.




references:
https://www.twilio.com/docs/glossary/what-virtual-phone-number