Getting 3 months free access to Plural Sight

PluralSight is a great resource to keep up to date with new technologies, or picking up new skills. Plural Sight offers courses ranging from Angular to Azure certification training. However, all of this comes with a steep yearly subscription cost. If you sign up for the trial, you can only watch a few hours of the lessons, not enough to make the decision to sign up for the membership.

If you are looking to try out plural sight, you can sign up for the Visual Studio Dev Essentials, and get free 3 MONTH access to the plural sight library, amongst other goodies.

There are three other educational resources that you can try out for a 3 month trial basis absolutely free through the site:

Opsgility: Online training and microsoft azure certification paths.

Linux Academy: Unlimited access to advanced online training and certification courses for 3 months.

WinintellectNOW: On-demand training for software developers: .NET, Xamarin, C#, JavaScript, Angular, Azure, and much more.

Click Here to Access the Visual Studio Dev Essentials Deal

Missing References for new Project

When you start a new Xamarin Forms project using Visual Studio, you often see a bunch of errors regarding missing dependencies. You might see something like:

Error CS0246: The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?) (CS0246)

There are a few things you can do to quickly resolve this issue:
1. Right click on Solution and select Rebuild Solution.
2. Close the project, and re-open it.
3. Go to Package Manager Console and attempt to update the dependencies.
4. Manually add the missing dependencies by right clicking on References and selecting Add References in the Solution Explorer.

NPM Setting corporate Proxy

If you work at any mid-large sized corporation, you are most likely working behind a proxy. In order to build your node projects, you have to set proxy for npm to make requests through.

npm config set proxy http://your.company.proxy.com:8080/  
npm config set https-proxy https://your.company.proxy.com:8080/  
npm config set strict-ssl false

The first two set the http and https proxies, while the last command turns the strict ssl off.

Jackson ObjectMapper 101

Jackson is a JSON processing library for Java. The code below will create an object mapper outputting JSON in pretty format and have case insensitive fields.

ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);

Jackson Wiki containing additional features:

Downloading file using Jersey

Very often, your application requires having a resource that allows users to download a file. This could be an endpoint where a user downloads some Report, their user data, or any other type of file.
To achieve this goal, you use StreamingOutput to copy the content of the file, and then add the stream to your Response object.

@GET
@Path("/download")
public Response download()
{
	String filename = "//someFolder/some-File.pdf"
	File file = new File(filename);
	final String newFileName = file.getName();
	StreamingOutput fileStream = output ->
	{
		try
		{
			java.nio.file.Path path = Paths.get(filename);
			byte[] data = Files.readAllBytes(path);
			output.write(data);
			output.flush();
		}
		catch (Exception e)
		{
			throw new WebApplicationException("File Not Found !!");
		}
	};
	return Response
			.ok(fileStream, MediaType.APPLICATION_OCTET_STREAM)
			.header("content-disposition", "attachment; filename = " + newFileName)
			.build();
}

How to view Closed sprints in Jira

Once you close a sprint, it’s removed from the “Active Sprints” drop down in your Jira board. To see the issues that were resolved in a closed sprint, and to get analytics on how well the sprint went, you have to go to “Reports” and select the closed off sprint from there.

Clicking on the Reports link from your project takes you to a page with the list of reports that are available.

On that page, you will see a drop down with the list of sprints that were closed. Once you select one, you can see the issues that were resolved, or moved out from that sprint, along with a burnout chart showing how well the sprint performed.

Using MongoDB with Spring Boot

Spring Boot is a powerful framework for building microservices. It comes ready to work with almost every type of database, including the newer NoSQL variety. This guide shows you how to quickly integrate MongoDB with your Spring Boot Application

Dependency

Spring Boot has hundreds of starter packages that allow you to avoid writing code. They have a starter for mongodb as well. Include the following dependency:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

Configuration

Add your database connection string in the your configuration file:

spring.data.mongodb.uri= mongodb://localhost:27017/mongodb

Model

Setup your entity model, just like you would for a traditional SQL entity


@Entity
@Data
public class Permit {
    @Id
    public String id;
    public String permitNum;
    public String revisionNum;
    public String permitType;
    public String structureType;
    public String work;
    public String streetNum;
    public String streetName;
    public String streetType;
    public String streetDirection;
    public String postal;
}

Setup Repository


public interface PermitRepository extends MongoRepository {
    List findAll();
}

That’s it! you can start using your Model to GET or POST data from your MongoDB Database

Menace of Unicode Domains

Spoofing is the age old method of tricking people to provide their information to malicious actors. Hackers have been spoofing email messages and domains by pretending to be someone else in hopes of gaining access to someones personal information. When ICANN decided to implement a new class of top-level domains, allowing the usage of ASCII in domains, it opened a whole new can of worms. Special characters like the Latin letter р are indistinguishable from the English letter p, allowing hackers to buy domains like “рayрal.com”. Although to the naked eye, this looks exactly the same as the payment processor PayPal.com, the Latin р in the domain make it a completely different domain, with different DNS point to a different resource. These special characters are encoded into what’s called Punycode1. The encoded version of the invalid paypal domain translates to http://xn--ayal-f6dc.com.

As of April 2017, all modern browsers automatically translate these unicode domains to their encoded punycodes, making it easier for users to avoid being the victims of spoofing attacks. However, a few months ago, some browsers left the unicode in the address bar, making it almost impossible for novice users (and most tech savvy users who were not paying attention) from recognising spoofing attempts. The Tech community raised this issue on twitter in March, forcing Chrome to release a fix that translates the Unicode domains in address bar.

 

  1. Punycode is a way to represent Unicode within the limited character set of ASCII used for internet host names.

Using H2 Database with Spring Boot

H2 is one of the more popular embedded databases out there today. Although there are 16-20 embedded databases out in the market, there are only 3 that work well with Spring (H2, Derby and HSQL).
Out of the three, H2 is considered the most matured and supported product. Although not recommended to use in production environment, H2 is robust enough to handle small scale production applications.

Using embedded H2 in Spring Boot is pretty simple. First you add the appropriate connection details in your configuration file, and then you can start using it in Spring like any other SQL database.

You need to add H2 as a maven dependency, there is no installs or setups required!

Dependency

<dependency>
     <groupId>com.h2database</groupId>
     <artifactId>h2</artifactId>
     <version>1.4.195</version>
</dependency>

Configuration

spring.datasource:
    driverClassName: org.h2.Driver
    url: jdbc:h2:mem:bootexample;MODE=MySQL

Data Model

Once you have your database setup, you can use it the same way you would use any other database in Spring. You create a model for your database entity

@Entity
@Table(name = "users")
public class User {
    @Id
    @GeneratedValue
    private Long id;
    @NotNull
    @NotEmpty
    private String firstName;
    @NotNull
    @NotEmpty
    private String lastName;
    @NotNull
    @NotEmpty
    private String password;
    @ValidEmail
    private String email;
    @NotNull
    @NotEmpty
    private String phoneNumber;
    private String lastOnline;
    private Boolean enabled;
    public String getLastOnline() {
        return lastOnline;

    }

    public void setLastOnline(String lastOnline) {
        this.lastOnline = lastOnline;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public Long getId() {
        return id;
    }


    public void setId(Long id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

Repository

Finally, you can use Spring’s JpaRepositoryto manipulate your data

package com.fullstacktrace.domain;

import com.fullstacktrace.domain.model.User;
import org.springframework.data.jpa.repository.JpaRepository;

public interface UserRepository extends JpaRepository<User, Integer> {
    public User findByEmail(String email);
}