Skip to content

Instantly share code, notes, and snippets.

/**
* Serialize the response into the DTO POJO.
* Assumption: Jackson Jar is in classpath
* @param strResponse
* @return
*/
protected EmployeeDto convertResponseJsonToPojo(String strResponse) {
ObjectMapper mapper = new ObjectMapper();
// Don't fail on unknown properties
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
import io.jsonwebtoken.Jwt;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.SignatureException;
import io.jsonwebtoken.impl.crypto.MacProvider;
import java.security.Key;
import java.time.Instant;
import java.time.LocalDate;
Class ... {
@sunieldalal
sunieldalal / Base64Example.java
Created July 27, 2015 17:34
Base64 username/pasword example
//Reference: http://ostermiller.org/utils/Base64.html
URL url = new URL("http://....");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty(
"Authorization",
"Basic " + Base64.encode(
username + ":" + password
)
);
InputStream in = connection.getInputStream();
public class NetezzaTest {
// Replace this with your logger implementation, if not using slf4j
private static final Logger LOGGER = LoggerFactory.getLogger(NetezzaTest.class);
public static void main(String[] args) {
try {
// Assumption is that Netezza driver is on classpath
LOGGER.info("Connecting to netezza database.");
Class.forName("org.netezza.Driver");
@Resource
private Environment env;
public String getUserName() {
return env.getRequiredProperty("APP.USERNAME");
}
public String getPassword() {
return env.getRequiredProperty("APP.PASSWORD");
}
@sunieldalal
sunieldalal / DatabaseConfig.java
Last active August 29, 2015 14:19
Spring_Hibernate_HIkariCP_SqlServer_Example
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.hibernate.ejb.HibernatePersistence;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@sunieldalal
sunieldalal / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sunieldalal
sunieldalal / MySql-CheatSheet.md
Last active August 29, 2015 14:10
Mysql cheat sheet

Mysql cheat sheet

Create new database

Prerequisites: Install Mysql DB. Opem My SQL command line client and login as root user.

-- Create database for application
CREATE DATABASE app_dev;