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
/**
* Maps Employees to mat-table data format
*
* @author Pavan Kumar Jadda
* @since 1.0.0
*/
private mapTableData(data: UserData[]) {
this.dataSource = new MatTableDataSource<UserData>(data);
if (this.optionalParamsPresent()) {
/**
* Update parameters after user enters search text or changes page selection
*
* @author Pavan Kumar Jadda
* @since 2.0.0
*/
updateRouteParameters($event: PageEvent | null) {
const params = {
pageIndex: this.paginator.pageIndex,
pageSize: this.paginator.pageSize,
<mat-form-field appearance="fill">
<mat-label>Filter</mat-label>
<input
[formControl]="searchTextControl"
matInput
(keyup)="applyFilter($event)"
placeholder="Ex. Mia"
#input
/>
</mat-form-field>
@pavankjadda
pavankjadda / FetchClient.md
Last active June 8, 2022 03:45
Reusable Fetch Client

Reusable Fetch Client

This gist shows code to create thin wrapper around browser fetch api and call it as FetchClient. But first lets see the usage of GET/POST requests

Usage

  1. Simple get request
FetchClient(url, HttpMethod.GET);
  1. POST request with Form Data
@pavankjadda
pavankjadda / Nginx Reverse proxy Config.md
Created May 19, 2022 22:41
Nginx Reverse proxy Config
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events
{
  worker_connections 1024;
@pavankjadda
pavankjadda / Angular Multi Stage Dockerfile.md
Last active May 19, 2022 22:21
Angular Multi Stage Dockerfile
###### Install dependencies only when needed ######
FROM node:16-alpine AS builder
ARG CONFIGURATION='dev'

# Make /app as working directory
WORKDIR /app

# Copy package.json file
COPY package.json .
@pavankjadda
pavankjadda / Spring Boot Integration Test.md
Last active December 22, 2021 23:35
Spring Boot Integration Test

@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles(value = "local")
@AutoConfigureMockMvc
@WithUserDetails(value = "jaddap2", userDetailsServiceBeanName = "customDbUserDetailsService")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PersonIntegrationTest
{
@pavankjadda
pavankjadda / Spring Boot Controller layer unit Test.md
Last active December 22, 2021 23:28
Spring Boot Controller layer unit Test
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ContextConfiguration(classes = {PresApplication.class})
@WithUserDetails(value = "demo_user", userDetailsServiceBeanName = "customDbUserDetailsService")
@AutoConfigureMockMvc
@ActiveProfiles(value = "local")
class PersonControllerTest
{
	@Autowired
	private MockMvc mockMvc;
@pavankjadda
pavankjadda / Spring Boot Service layer unit Test.md
Created December 22, 2021 23:01
Spring Boot Service layer unit Test.md
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles(value = "local")
@AutoConfigureMockMvc
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class EmployeeServiceTest
{
	@Mock
	EmployeeRepository employeeRepository;
@pavankjadda
pavankjadda / Spring Boot Repository layer unit Test.md
Created December 22, 2021 22:43
Spring Boot Repository layer unit Test.md
@ExtendWith(SpringExtension.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ContextConfiguration(classes = {MyApplication.class})
@ImportAutoConfiguration(RefreshAutoConfiguration.class)
@ActiveProfiles(value = "local")
class EmployeeRepositoryTest
{
	@Autowired