Skip to content

Instantly share code, notes, and snippets.

View pavankjadda's full-sized avatar
😀
Follow me on Twitter @pavankjadda

Pavan Kumar Jadda pavankjadda

😀
Follow me on Twitter @pavankjadda
View GitHub Profile
@pavankjadda
pavankjadda / Liquibase Test and Production commands.md
Last active July 15, 2020 22:23
Liquibase Test and Production commands.md
  1. Generate changeset between Dev and Test databases
$ mvn liquibase:diff -Ptest -Dliquibase.url="jdbc:mysql://localhost:3306/liquibasedemo-test?serverTimezone=UTC" -Dliquibase.username="root" -Dliquibase.password="bcmc1234" -Dliquibase.referenceUrl="jdbc:mysql://localhost:3306/liquibasedemo-dev?serverTimezone=UTC" -Dliquibase.referenceUsername="root" -Dliquibase.referencePassword="bcmc1234"

  1. Apply change sets to Test database
$ mvn liquibase:update -Ptest -Dliquibase.url="dbc:mysql://localhost:3306/liquibasedemo-test?serverTimezone=UTC" -Dliquibase.username="username" -Dliquibase.password="password"
@pavankjadda
pavankjadda / Delete git tag local and remote.md
Created August 5, 2020 05:15
Delete git tag local and remote

Delete local git tag

$  git tag -d <tagname>

Delete remote git tag

$ git push --delete origin <tagname>
@pavankjadda
pavankjadda / Docker Health Check.md
Last active August 21, 2020 21:24
Docker Health Check.md
## Use OpenJDK 11 slim image
FROM adoptopenjdk:11-jre-openj9-bionic

### Copy JAR file from local machine to container
COPY target/*.jar app.jar

### Expose the port
EXPOSE 8080
@pavankjadda
pavankjadda / Delete git cache.md
Created September 4, 2020 22:49
Delete git cache
git rm  -r --cached .

git add .

git commit -m "Commit after cleaning git cache"

git push origin master
@pavankjadda
pavankjadda / Jwt Spring Security pom.xml .md
Created September 12, 2020 19:03
Jwt Spring Security pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.3.3.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
@pavankjadda
pavankjadda / JwtUtil.java.md
Last active September 13, 2020 05:25
JwtUtil
private String createToken(Map<String, Object> claims, String subject)
	{
		return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
				.setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24))
				.signWith(Keys.hmacShaKeyFor(coreProperties.getJwtSecret().getBytes()), SignatureAlgorithm.HS512).compact();
	}
	
public boolean validateToken(String token, UserDetails userDetails)
	{
@pavankjadda
pavankjadda / Security Config.md
Created September 12, 2020 19:24
Security Config
package com.pj.jwt.security;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.BeanIds;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@pavankjadda
pavankjadda / app.component.ts.md
Last active October 2, 2020 20:59
Synchronous HTTP calls - app.component.ts
async createEmployee()
{
    let url = API_URL + 'employees';
    let employee = new Employee();
    employee.id = Math.floor(Math.random() * 10000);
    employee.firstName = "John";
    employee.lastName = "McCain" + employee.id;

 //Wait for POST operation to complete then return response
@pavankjadda
pavankjadda / employee.service.ts.md
Created October 2, 2020 21:00
employee.service.ts
async createEmployee(url:string,employee: Employee)
{
  return await this.httpClient.post(url, employee).toPromise();
}
  
getEmployees(url:string)
{
  return this.httpClient.get<Employee[]>(url);
}
@pavankjadda
pavankjadda / H2 Database Initialization in Spring Boot.md
Last active October 7, 2020 23:03
How to insert data in to H2 database during Spring Boot Application startup
  1. Create schema.sql file src/main/resources directory. This file contains all DDL statements
  2. Create data.sql file in src/main/resources directory. This file contains all DML statements(insert,update statements)
  3. Create the application.yml file with following config
spring:
  datasource:
    url: jdbc:h2:mem:db
    username: admin
    password: admin
 initialization-mode: always