Skip to content

Instantly share code, notes, and snippets.

View iamitshri's full-sized avatar
🦉
Focusing

iamitshri iamitshri

🦉
Focusing
View GitHub Profile
@iamitshri
iamitshri / remove-merge.txt
Last active February 20, 2019 23:18
Remove merge commit
$ git revert -m 1 mergeCommitNumber
https://www.christianengvall.se/undo-pushed-merge-git/
https://education.github.com/git-cheat-sheet-education.pdf
@iamitshri
iamitshri / elastic-search-research.md
Created February 1, 2019 18:34
elastic search research
@iamitshri
iamitshri / fetch-data-using-pages.java
Created January 31, 2019 14:23
Fetch data using Spring data paging
int page = 0;
Page<Entity> pages = repo.findAll(PageRequest.of(page, 1000));
while(!pages.isLast()) {
List<Entity> content = pages.getContent();
// Do your thing with the content
Pageable pageable = pages.nextPageable();
pages = submissionRepo.findAll(pageable);
log.info("page number {} size:{}, offset:{}",pageable.getPageNumber(),pageable.getPageSize(),pageable.getOffset());
}
@iamitshri
iamitshri / elastic-search-6.2.2.properties
Created January 29, 2019 19:19
Spring boot application properties for setting up elastic search
spring.data.elasticsearch.cluster-nodes=localhost:9300
spring.data.elasticsearch.properties.cluster.name=elasticsearch
spring.data.elasticsearch.properties.client.transport.sniff=true
spring.data.elasticsearch.properties.client.transport.ignore_cluster_name=true
spring.data.elasticsearch.properties.client.transport.ping_timeout=5s
spring.data.elasticsearch.properties.client.transport.nodes_sampler_interval=5s
@iamitshri
iamitshri / logstash-jdbc.conf
Last active January 25, 2019 23:33
Logstash get incremental updates based on last run value
input {
jdbc {
jdbc_driver_library => "/Users/Path/dev-apps/logstash-6.5.4/mysql-java-connector/mysql-connector-java-5.1.46.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/elastic-search-test"
schedule => "* * * * *"
jdbc_user => "root"
jdbc_password => "mysqlN01"
statement => "SELECT * from person where id > :sql_last_value"
jdbc_paging_enabled => "true"
@iamitshri
iamitshri / regexCheatsheet.js
Created January 15, 2019 18:27 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@iamitshri
iamitshri / spring-boot-project.html
Last active January 12, 2019 03:05
One click Spring boot project
<h1>
This link helps to quickly create a sample spring boot project
</h1>
https://start.spring.io/starter.zip?name=autoTestExperiment&groupId=edu.wgu.ema&artifactId=autoTestExperiment&version=0.0.1-SNAPSHOT&description=Demo+project+for+Spring+Boot&packageName=edu.wgu.ema.katas&type=maven-project&packaging=jar&javaVersion=1.8&language=java&bootVersion=1.5.19.RELEASE&dependencies=lombok&dependencies=configuration-processor&dependencies=devtools&dependencies=mysql&dependencies=data-jpa&dependencies=web
------- ----------
@iamitshri
iamitshri / Stopwatch.java
Created December 10, 2018 02:44
Using stopwatch from package org.apache.commons.lang3.time
package com.amit;
import org.apache.commons.lang3.time.StopWatch;
import lombok.extern.slf4j.Slf4j;
/**
* Hello world!
*
*/
@iamitshri
iamitshri / get-File.java
Last active November 26, 2018 17:55
Get Files under the folder in src/main/resources in spring boot app
private void getFile() throws IOException {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
List<Resource> files = Arrays.asList(resolver.getResources("classpath*:folder-name"));
for(Resource file : files) {
for(File file1 : file.getFile().listFiles()) {
}
}
@iamitshri
iamitshri / logback.xml
Created November 25, 2018 18:24
Logback configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="logPattern"
value="%d %-5level %logger{35} - %msg%n" />
<property name="logEncoding" value="UTF-8" />
<property name="logDirectory" value="logs" />