Upgrade your angular CLI global version

Run below commands:

npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli@latest 
 
Depending on your system, you may need to prefix the above commands with sudo.
 

Upgrade your local project angular CLI

go to in your project directory:

cd /home/rahul/angular-projects/test

then run below commands:

rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install

Upgrade your npm global version to latest

Run  below command:

sudo npm i -g npm

Upgrade angular 4 project to angular 5

Go to in your project directory:

cd /home/rahul/angular-projects/test-proj

then run below two commands one by one:

npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@'^5.0.0' typescript@2.4.2 rxjs@'^5.5.2'

npm install typescript@2.4.2 --save-exact

No such file or directory in /opt/lampp/htdocs/wplms/wp-includes/wp-db.php

Correct the DB_HOST entry in wp-config.php like:

define('DB_HOST', 'localhost:/var/lib/mysql/mysql.sock');

The file path of mysql.sock it varies according to your os / setup. So make it correct accordingly.

Ionic2 remove click delay

In general, Ionic2 recommend only adding (click) events to elements that are normally clickable. This includes <button> and <a> elements. This improves accessibility as a screen reader will be able to tell that the element is clickable.

However, you may need to add a (click) event to an element that is not normally clickable. When you do this you may experience a 300ms delay from the time you click the element to the event firing. To remove this delay, you can add the tappable attribute to your element.

<div tappable (click)="doClick()">I am clickable!</div>

Java Microsoft OAuth2 get Access Token

private String getAccessToken(String authorizationCode, String clientId, String clientSecret, String redirectUri)  throws Exception {
        String accessToken = "";
        try {

            LOGGER.info("GET MSFT Access Token---code---" + code);

            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost postRequest = new HttpPost("https://login.live.com/oauth20_token.srf");

            List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
            urlParameters.add(new BasicNameValuePair("grant_type", "authorization_code"));
            urlParameters.add(new BasicNameValuePair("client_id", clientId));
            urlParameters.add(new BasicNameValuePair("client_secret", clientSecret));
            urlParameters.add(new BasicNameValuePair("code", code));
            urlParameters.add(new BasicNameValuePair("redirect_uri", redirectUri));

            postRequest.setEntity(new UrlEncodedFormEntity(urlParameters));

            HttpResponse response = httpClient.execute(postRequest);

            if (response.getStatusLine().getStatusCode() != 200) {
                 throw new Exception("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
            }
            BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            StringBuilder sb = new StringBuilder();
            String output;

            while ((output = br.readLine()) != null) {
                sb.append(output);
            }
            br.close();
            LOGGER.info("MSFT JSON Object" + sb);

            JSONObject jsonObject = new JSONObject(sb.toString());
            accessToken = jsonObject.getString("access_token");

            httpClient.getConnectionManager().shutdown();

        } catch (IOException | JSONException e) {
            LOGGER.error("Error in MSFT getAccessToken()", e);
        }
        return accessToken;
    }

Java Microsoft OAuth2 get User Profile

private String getProfile(String authrizationCode, String accessToken) throws Exception {
        StringBuilder sb = new StringBuilder();
        try {

            LOGGER.info("GET MSFT Profile---code---" + code);

            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet getRequest = new HttpGet(
                    "https://apis.live.net/v5.0/me?access_token=" + accessToken + "&format=json");
            HttpResponse response = httpClient.execute(getRequest);

            if (response.getStatusLine().getStatusCode() != 200) {
                 throw new Exception("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
            }
            BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            String output;

            while ((output = br.readLine()) != null) {
                sb.append(output);
            }
            br.close();
            LOGGER.info("MSFT JSON Object" + sb);

        } catch (IOException e) {
            LOGGER.error("Error in MSFT getProfile()", e);
        }
        return sb.length() > 0 ? JsonUtils.getJsonString(JSONValue.parse(sb.toString())) : "{}";
    }



Java Microsoft OAuth2 get Access Token 

Java Google OAuth2 get User Profile

private String getProfile(String authCode, String accessToken) throws Exception {
        StringBuilder sb = new StringBuilder();
        try {

            LOGGER.info("get Google Profile---accessToken---" + accessToken);
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet getRequest = new HttpGet(
                    "https://www.googleapis.com/plus/v1/people/me"
                            + "?access_token=" + accessToken);
            HttpResponse response = httpClient.execute(getRequest);

            if (response.getStatusLine().getStatusCode() != 200) {
                 throw new Exception("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
            }
            BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            String output;

            while ((output = br.readLine()) != null) {
                sb.append(output);
            }
            br.close();
            LOGGER.info("JSON Object" + sb);

        } catch (IOException e) {
            LOGGER.error("Error in getGoogleProfile()", e);
        }
        return sb.length() > 0 ? JsonUtils.getJsonString(JSONValue.parse(sb.toString())) : "{}";
    }

Java LinkedIn OAuth2 get Profile

private String getProfile(String code, String accessToken) throws Exception {
        StringBuilder sb = new StringBuilder();
        try {

            LOGGER.info("get LinkedIn Profile---code---" + code);

            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet getRequest = new HttpGet(
                    "https://api.linkedin.com/v1/people/~:(id,num-connections,picture-url,email-address,first-name,last-name)?oauth2_access_token="
                            + accessToken + "&format=json");
            getRequest.addHeader("oauth2_access_token", code);
            HttpResponse response = httpClient.execute(getRequest);

            if (response.getStatusLine().getStatusCode() != 200) {
                  throw new Exception("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
            }
            BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            String output;

            while ((output = br.readLine()) != null) {
                sb.append(output);
            }
            br.close();
            LOGGER.info("JSON Object" + sb);

        } catch (IOException e) {
            LOGGER.error("Error in getLinkedInProfile()", e);
        }
        return sb.length() > 0 ? JsonUtils.getJsonString(JSONValue.parse(sb.toString())) : null;
    }