Skip to content

Instantly share code, notes, and snippets.

@chethanbandi
chethanbandi / ListJMXBeans.java
Created February 17, 2021 05:54
List JMX Beans
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
package com.adzcentral.core.service;
import java.io.IOException;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
import org.junit.Test;
@chethanbandi
chethanbandi / JdbcUtil.java
Last active February 17, 2021 05:58
jdbc helper
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
String sql = "insert into report(name, userId, config) values(?, ?, ?)";
try (Connection con = dataSource.getConnection()) {
try (PreparedStatement preparedStatement = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
preparedStatement.setString(1, request.get(NAME).asText());
preparedStatement.setInt(2, 0);
preparedStatement.setString(3, request.get(CONFIG).toString());
preparedStatement.execute();
ResultSet rs = preparedStatement.getGeneratedKeys();
if (rs.next()) {
int reportId = rs.getInt(1);
@chethanbandi
chethanbandi / App.java
Created November 22, 2016 13:35
paypal reference transaction example
package com.cbandi.billing;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
@chethanbandi
chethanbandi / latency.markdown
Created November 15, 2016 03:37 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@chethanbandi
chethanbandi / aws-ecs-deploy.sh
Created June 21, 2016 05:40
AWS ecs deployment
NAME=server
ECR=<repo_url>
VERSION=${BUILD_NUMBER}
TAG=${ECR}/${NAME}:${VERSION}
eval $(aws ecr get-login)
docker build -t $TAG .
if[ $? -ne 0 ];then
echo "Docker build failed exiting"
@chethanbandi
chethanbandi / nextbuild.groovy
Created June 20, 2016 04:44
jenkins-nextbuild
//If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)