This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.List; | |
| import java.util.ArrayList; | |
| /* | |
| * ArrayList is a part of collection framework and is present in java.util package. | |
| * It provides us dynamic arrays in Java. | |
| * Though, it may be slower than standard arrays but can be helpful in programs where lots of manipulation in the array is needed. | |
| */ | |
| public class ArrayListExample { | |
| public static void main(String[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.LinkedList; | |
| import java.util.List; | |
| /* | |
| *In Java, LinkedList class implements the list interface. | |
| This class consists of the following methods : | |
| 1. boolean add(Object element) : It appends the element to the end of the list. | |
| 2. void add(int index, Object element): It inserts the element at the position ‘index’ in the list. | |
| 3. void addFirst(Object element) : It inserts the element at the beginning of the list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var str = "Hello,\nMy name is, Bob!\n"; | |
| str.replace(/(\r\n|\n|\r)/gm,""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Within these normal 2 steps you will be able to connect your domain name with your EC2 instance and will be accessible publicly/Globally. | |
| 1. Allocate the elastic ip | |
| 2. Connect it with your Domain name using DNS manager of your registrar. | |
| Let me explain more. | |
| #1. Allocate an elastic IP for the EC2 instance you are integrating. | |
| - Login with AWS, Find EC2 in AWS management console, go to Instance page. | |
| - Find Elastic IPs page and click on "Allocate new address". | |
| - After that, Click on Allocation button. Once it will be allocated, you need to bind it with your Instance, otherwise you may charge some amount. | |
| - Go to Instances screen, Right-click on the row of the newly created elastic IP, and click on Associate address. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| If you are working with angular and when you need to refresh component without navigation on another component or instead of using window.location.reload() or location.reload(), you can follow below code in your project: | |
| <code>mySubscription: any;<code> | |
| Adding following code snippet to the required component’s constructor will work. | |
| this.router.routeReuseStrategy.shouldReuseRoute = function () { | |
| return false; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Inject, Injectable } from '@angular/core'; | |
| import { Http } from '@angular/http'; | |
| import { Observable } from 'rxjs/Rx'; | |
| @Injectable() | |
| export class AppConfig { | |
| private config: Object = null; | |
| private environment: Object = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getTitle = async (page) => { | |
| const title = await page.evaluate(() => { | |
| const ogTitle = document.querySelector('meta[property="og:title"]'); | |
| if (ogTitle != null && ogTitle.content.length > 0) { | |
| return ogTitle.content; | |
| } | |
| const twitterTitle = document.querySelector('meta[name="twitter:title"]'); | |
| if (twitterTitle != null && twitterTitle.content.length > 0) { | |
| return twitterTitle.content; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getDescription = async (page) => { | |
| const description = await page.evaluate(() => { | |
| const ogDescription = document.querySelector( | |
| 'meta[property="og:description"]' | |
| ); | |
| if (ogDescription != null && ogDescription.content.length > 0) { | |
| return ogDescription.content; | |
| } | |
| const twitterDescription = document.querySelector( | |
| 'meta[name="twitter:description"]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getDomainName = async (page, uri) => { | |
| const domainName = await page.evaluate(() => { | |
| const canonicalLink = document.querySelector("link[rel=canonical]"); | |
| if (canonicalLink != null && canonicalLink.href.length > 0) { | |
| return canonicalLink.href; | |
| } | |
| const ogUrlMeta = document.querySelector('meta[property="og:url"]'); | |
| if (ogUrlMeta != null && ogUrlMeta.content.length > 0) { | |
| return ogUrlMeta.content; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const util = require("util"); | |
| const request = util.promisify(require("request")); | |
| const getUrls = require("get-urls"); | |
| const urlImageIsAccessible = async url => { | |
| const correctedUrls = getUrls(url); | |
| if (correctedUrls.size !== 0) { | |
| const urlResponse = await request(correctedUrls.values().next().value); | |
| const contentType = urlResponse.headers["content-type"]; | |
| return new RegExp("image/*").test(contentType); |
OlderNewer