Saturday, December 8, 2018

Android : How to show user image on the marker, zoom to fit all the markers

Below is the code to do this!

public void updateMapWithUserLocations(){
        final ArrayList markers = new ArrayList();
        targets = new ArrayList();

        for (int i = 0 ; i < users.length; i++){
            final LatLng location = locations[i];
            final String imageURL = images[i];
            Target target = null;
            Marker userMarker = mMap.addMarker(new MarkerOptions()
                    .position(location)
                    .icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.location_icon)))
                    .title("test")
                    .snippet("test address")
            );
            markers.add(userMarker);
            PicassoTarget pTarget = new PicassoTarget(userMarker);
            targets.add(pTarget);
            Picasso.with(this)
                    .load(imageURL)
                    .resize(100,100)
                    .centerCrop()
                    .transform(new BubbleTransformation(5))
                    .into(pTarget);

        }
        fitAlMarkersInZoom(mMap,markers);
    }

    class PicassoTarget implements Target{
        private Marker marker;

        PicassoTarget(Marker marker){
            this.marker = marker;
        }

        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            this.marker.setIcon(BitmapDescriptorFactory.fromBitmap(bitmap));
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {

        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {

        }
    }


    private void fitAlMarkersInZoom(GoogleMap googleMap, ArrayList markers){

        try{
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            for (Marker marker : markers) {
                builder.include(marker.getPosition());
            }
            final LatLngBounds bounds = builder.build();

            try {
                mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
            } catch (IllegalStateException e) {
                // layout not yet initialized
                final View mapView = getFragmentManager()
                        .findFragmentById(R.id.map).getView();
                if (mapView.getViewTreeObserver().isAlive()) {
                    mapView.getViewTreeObserver().addOnGlobalLayoutListener(
                            new ViewTreeObserver.OnGlobalLayoutListener() {
                                @SuppressWarnings("deprecation")
                                @SuppressLint("NewApi")
                                // We check which build version we are using.
                                @Override
                                public void onGlobalLayout() {
                                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                                        mapView.getViewTreeObserver()
                                                .removeGlobalOnLayoutListener(this);
                                    } else {
                                        mapView.getViewTreeObserver()
                                                .removeOnGlobalLayoutListener(this);
                                    }
                                    mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
                                }
                            });
                }
            }
        }
        catch (Exception ex){
            ex.printStackTrace();
        }
    }

GCP : What is Cloud IAM


Cloud Identity & Access Management (Cloud IAM) lets administrators authorize who can take action on specific resources, giving you full control and visibility to manage cloud resources centrally. For established enterprises with complex organizational structures, hundreds of workgroups, and potentially many more projects, Cloud IAM provides a unified view into security policy across your entire organization, with built-in auditing to ease compliance processes.

Leverage Cloud Identity, Google Cloud’s built-in managed identity to easily create or sync user accounts across applications and projects. Cloud Identity makes it easy to provision and manage users and groups, set up single sign-on, and configure multi-factor authentication directly from the Google Admin Console. With Cloud Identity you get access to the GCP Organization, which enables you to centrally manage projects via the Cloud Resource Manager.

Cloud IAM provides the right tools to manage resource permissions with minimum fuss and high automation. Map job functions within your company to groups and roles. Users get access only to what they need to get the job done, and admins can easily grant default permissions to entire groups of users.


Cloud IAM enables you to grant access to cloud resources at fine-grained levels, well beyond project-level access.

Create more granular access control policies to resources based on attributes like device security status, IP address, resource type, and date/time. These policies help ensure that the appropriate security controls are in place when granting access to cloud resources.

A full audit trail history of permissions authorization, removal, and delegation gets surfaced automatically for your admins. Cloud IAM lets you focus on business policies around your resources and makes compliance easy.

Control resource permissions using a variety of options: graphically from the Cloud Platform console, programmatically via Cloud IAM methods, or using the gcloud command line interface.


references:
https://cloud.google.com/iam/

Friday, December 7, 2018

What is Google Play Protect?


Google Play Protect is Google's built-in malware protection for Android. Backed by the strength of Google's machine learning algorithms, it is always improving in real time.

Google Play Protect continuously works to keep your device, data and apps safe. It automatically scans your device and makes sure that you have the latest in mobile security, so you can rest easy.

If you’ve misplaced your device, Find My Device has your back. You can locate it by signing into your Google account, or even call it directly from your browser. Lock your device remotely or display a message on the lock screen, so if someone finds it they know who to contact. Plus, if you’re convinced that it’s lost for good you can delete all your data.

All Android apps undergo rigorous security testing before appearing in the Google Play Store. We vet every app and developer in Google Play, and suspend those who violate our policies. Then, Play Protect scans billions of apps daily to make sure that everything remains spot on. That way, no matter where you download an app from, you know it’s been checked by Google Play Protect.

With Safe Browsing protection in Chrome, you can browse with confidence. If you visit a site that's acting out of line, you'll be warned and taken back to safety.

references:
https://www.android.com/play-protect/

Thursday, December 6, 2018

GCP : What is Cloud Interconnect

Cloud Interconnect provides low latency, highly available connections that enable you to reliably transfer data between your on-premises and VPC networks. Also, Cloud Interconnect connections provide RFC 1918 communication, which means internal (private) IP addresses are directly accessible from both networks.

Cloud Interconnect offers two options for extending your on-premises network. Google Cloud Interconnect - Dedicated (Dedicated Interconnect) provides a direct physical connection between your on-premises network and Google’s network. Google Cloud Interconnect - Partner (Partner Interconnect) provides connectivity between your on-premises and GCP VPC networks through a supported service provider.

Benefits of cloud interconnect

Benefits of Cloud Interconnect

    Traffic between your on-premises network and your VPC network doesn't traverse the public Internet. Traffic traverses a dedicated connection or through a service provider with a dedicated connection. By bypassing the public Internet, your traffic takes fewer hops, so there are less points of failure where your traffic might get dropped or disrupted.

Your VPC network's internal (RFC 1918) IP addresses are directly accessible from your on-premises network. You don't need to use a NAT device or VPN tunnel to reach internal IP addresses. Currently, you can't use Cloud Interconnect to access external (non-RFC 1918) IP addresses; instead, you must use a separate connection, such as Carrier Peering.

You can scale your connection to Google based on your needs. For Dedicated Interconnect, connection capacity is delivered over one or more 10 Gbps Ethernet connections, with a maximum of eight connections (80 Gbps total per interconnect). For Partner Interconnect, connection capacity for each VLAN can range from 50 Mbps to 10 Gbps.

The cost of egress traffic from your VPC network to your on-premises network is reduced. Cloud Interconnect is generally the least expensive method if you have a high-volume of traffic to and from Google’s network.

Considerations

If you don't require the low latency and high availability of Cloud Interconnect, consider using Cloud VPN to set up IPsec VPN tunnels between your networks. IPsec VPN tunnels encrypt data by using industry standard IPsec protocols as traffic traverses the public Internet.

An IPsec VPN tunnel doesn't require the overhead or costs that are associated with a direct, private connection. Cloud VPN only requires a VPN device in your on-premises network.



References:
https://cloud.google.com/interconnect/docs/concepts/overview

Git : How to sync a forked repository with its original

Open the forked Git repository me/foobar
Click on Compare:



You will get the notification:

    There isn't anything to compare.
    someone:master is up to date with all commits from me:master. Try switching the base for your comparison.

Click on switching the base on this page:






Then you get to see all the commits made to someone/foobar after the day you forked it.
Click on Create pull request:





Give the pull request a title and maybe a description and click Create pull request.

On the next page, scroll to the bottom of the page and click Merge pull request and Confirm merge.

Your Git repository me/foobar will be updated.


References:
https://stackoverflow.com/questions/20984802/how-can-i-keep-my-fork-in-sync-without-adding-a-separate-remote/21131381#21131381

HTML, CSS : Hotel reservation template

This has a cool feature where the floating menu appear only when the screen width is lesser.
This is achieved by the w3-collapse css style. w3-top indicates the bar should float on top.
w3-sidebar indicates this should be a side bar.  W3-sidebar is nothing but like below

w3-sidebar{height:100%;width:200px;background-color:#fff;position:fixed!important;z-index:1;overflow:auto}

For each of the media queries, it is done like the below

@media (max-width:768px){.w3-modal-content{width:500px}.w3-modal{padding-top:50px}}
@media (min-width:993px){.w3-modal-content{width:900px}.w3-hide-large{display:none!important}.w3-sidebar.w3-collapse{display:block!important}}
@media (max-width:992px) and (min-width:601px){.w3-hide-medium{display:none!important}}
@media (max-width:992px){.w3-sidebar.w3-collapse{display:none}.w3-main{margin-left:0!important;margin-right:0!important}.w3-auto{max-width:100%}}

On smaller screens, the top bar is having a menu, and it is done using header class.

This page also has a slide show and the implementation is like this

Below is the snippet that helps in showing and hiding the side bar.

function w3_open() {
    document.getElementById("mySidebar").style.display = "block";
    document.getElementById("myOverlay").style.display = "block";
}

function w3_close() {
    document.getElementById("mySidebar").style.display = "none";
    document.getElementById("myOverlay").style.display = "none";
}


Another important item is w3-modal which is displaying a modal dialog. The contents inside this are represented with w3-modal-content
And w3-animate-zoom w3-padding-large are playing major role in experience of these.



References:
https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_templates_apartment_rental&stacked=h

Wednesday, December 5, 2018

CSS Template : Architects Template



It uses the CSS templates from the W3C, and most of the pages really look good. With the architects template, main things are

Navbar:

w3-bar is the main class for it.
w3-card gives the effect of embossed
header is used for the header area.
Inside the header area, if need to w3-display-middle



 

    BR Architects
   
   

      Projects
      About
      Contact
   

 


The w3-top helps to define the navigation bar which floats on the entire page.



  Architecture
 

   

BR Architects


 


Header


Header area

Paragraph

Column with text

References:
https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_templates_architect&stacked=h