Skip to content

Instantly share code, notes, and snippets.

View ListJMXBeans.java
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;
View JacksonTypeInfoTest.java
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;
View JdbcUtil.java
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;
View PlainJdbc.java
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 Nov 22, 2016
paypal reference transaction example
View App.java
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 Nov 15, 2016 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
View latency.markdown

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

View aws-ecs-deploy.sh
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"
View nextbuild.groovy
//If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)