Skip to content

Instantly share code, notes, and snippets.

View iamitshri's full-sized avatar
🦉
Focusing

iamitshri iamitshri

🦉
Focusing
View GitHub Profile
Stream.of("Bob hit a ball, the hit BALL flew far after it was hit.".split("\\W"))
.filter(a->!a.trim()
.isEmpty())
.map(a -> a.trim().toLowerCase())
.filter(s ->!s.equals("hit"))
.collect(Collectors.groupingBy(Function.identity(),Collectors.counting()))
.entrySet()
.stream()
.max(Comparator.comparing(a->a.getValue()))
.get();
@iamitshri
iamitshri / GetBearerTokenAndCallPostEndpoint.java
Last active December 30, 2019 04:06
Get Bearer Token And Call a Post Endpoint
package app.service;
@Slf4j
@Service
@RequiredArgsConstructor
public class Service {
@Autowired
@iamitshri
iamitshri / inside-pom.xml
Created July 10, 2019 15:18
querydsl setup
<!-- QueryDSL -->
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
</dependency>
@iamitshri
iamitshri / timcat.settings.properties
Created June 6, 2019 16:09
springboot Tomcat settings
server.connection-timeout=60000
#https://tomcat.apache.org/tomcat-9.0-doc/config/http.html
#server.connectionUploadTimeout=3600000
#server.disableUploadTimeout=false
## Access logs
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.suffix=.log
server.tomcat.accesslog.prefix=access_log
@iamitshri
iamitshri / pom.xml
Created June 6, 2019 03:43
querydsl support
<!-- This Annotation processor plugin is used by QueryDsl -->
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
@iamitshri
iamitshri / regex.java
Last active May 29, 2019 04:35
Regex Lookahead Lookbehind
POSITIVE LOOKAHEAD
(?<=e)I.*? --> 'empIloyeeId' --> Matches only 'I' if its preceded by e
Negative LookBEHIND
(?<!e)I.*? --> 'empIloyeeId' --> Matches only 'I' if its NOT preceded by e
@iamitshri
iamitshri / formatter.java
Created May 27, 2019 21:28
@Formatter:off stop formatting code block
//@formatter:off
code that you do not want to format using eclipse
// @formatter:on
@iamitshri
iamitshri / branch-rename.git
Last active May 19, 2019 19:39
Git branch rename
git branch -m new-name
git push origin :develop.rdb new-name
Reference: https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/
check the documentation git branch --help
public static <E> List<E> readJsonFile(TypeReference<List<E>> typeReference, String jsonFileName) {
List<E> list = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
InputStream inputStream = TypeReference.class.getResourceAsStream(jsonFileName);
try {
list = mapper.readValue(inputStream, typeReference);
} catch (IOException e) {
e.printStackTrace();
}
return list;
@iamitshri
iamitshri / random-pojos.txt
Created March 13, 2019 23:17
generate random Java objects using podam, random-beans
https://github.com/benas/random-beans