Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jpukg's full-sized avatar
🧭
Full Stack Developer (Java, Angular)

Jayaprakash / JP jpukg

🧭
Full Stack Developer (Java, Angular)
  • Brussels, Belgium
View GitHub Profile
@jpukg
jpukg / ReadExcelColumnValues.java
Last active June 10, 2022 16:00
Read a particular column values from excel - Apache POI
public class ReadExcelColumnValues {
public static void main(String[] args) throws IOException {
String sheetName = "Sheet2";
String columnName = "Status";
String[][] sheetValues = getSheetData(App.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "\\Test-excel.xls", sheetName);
List<String> columnValues = getColumnValues(getColumnPosition(columnName, sheetValues), sheetValues);
System.out.println(columnValues);
}
private static List<String> getColumnValues(int columnPosition, String[][] sheetValues) {
@jpukg
jpukg / ExportTableSnapshotsServiceImpl.java
Created May 12, 2022 13:29
Getting large number of records from database without having primary cache + Separate entity manager
public List<Employee> findAllEmployee(int offset, int limit) {
String employeeQuery = String.format("select distinct r from %s r left join r.owner as u", Employee.class);
employeeQuery += " WHERE r.status = :status ORDER BY r.lastModification DESC";
EntityManagerFactory factory = Persistence.createEntityManagerFactory("employee_ds");
EntityManager shortLiveEntityManager = factory.createEntityManager();
TypedQuery<RISIndex> query = shortLiveEntityManager.createQuery(employeeQuery, Employee.class).setFlushMode(FlushModeType.COMMIT);;
query.setParameter("status", Status.APPROVED);
query.setHint(QueryHints.QUERY_RESULTS_CACHE, false);
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.CheckCacheThenDatabase);
List<RISIndex> resultList = query
@jpukg
jpukg / Java 8 Patterns Cheatsheet.md
Created May 3, 2022 15:48 — forked from jiffle/Java 8 Patterns Cheatsheet.md
Cheatsheet of Standard Design Patterns implemented using Java 8 Lambdas

Design Patterns implemented in Java 8

These patterns are implemented using Java 8 Lambdas (together with Project Lombok annotations).

Factory Pattern

Factory I : No Parameter Constructor

Enum class:

@jpukg
jpukg / CloseableTemplate.java
Created May 2, 2022 20:02 — forked from jstrachan/CloseableTemplate.java
helper class for working with closeable resources like streams
/**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@jpukg
jpukg / keyboard-listener.component.ts
Created April 27, 2022 16:21 — forked from rakia/keyboard-listener.component.ts
Handling Keyboard Listener in Angular
import { Component, HostListener } from '@angular/core';
@Component({
selector: 'app-keyboard-listener',
templateUrl: './keyboard-listener.component.html',
styleUrls: ['./keyboard-listener.component.css']
})
export class KeyboardListenerComponent {
// Listener just for one key
@jpukg
jpukg / go_cheatsheet.md
Created February 14, 2022 21:00 — forked from tysonpaul89/go_cheatsheet.md
Go Cheatsheet

Go

Go is a statically typed, compiled programming language designed at Google. Go is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency.

This cheat sheet is prepared by refering the book Introducing Go Build Reliable, Scalable Programs by Caleb Doxsey

Topics

@jpukg
jpukg / go-notes.md
Created February 14, 2022 20:59 — forked from bnguyensn/go-notes.md
Go notes

Go Notes

CLI

The most important Go CLIs:

Command Description
go build Compile packages and dependencies
go fmt Format package sources
@jpukg
jpukg / go_note.md
Created February 14, 2022 20:59 — forked from baddri/go_note.md
Go notes
@jpukg
jpukg / map-to-struct-with-json.go
Created February 14, 2022 20:59 — forked from kwmt/map-to-struct-with-json.go
map -> json -> struct
package main
import (
"encoding/json"
"fmt"
)
type example struct {
Name string
Address string