Skip to content

Instantly share code, notes, and snippets.

View visvv's full-sized avatar

Vishnu V V visvv

View GitHub Profile
package vv.groovy.jdbc
import groovy.sql.Sql;
/**
* Created by vasudvis on 4/25/2017.
*/
class Connection {
public static void main(String[] args) {
println 'sample'
checkConnection();
def listFiles(String path){
def file = new File(path);
if(!file.exists()){
println 'wrong path';
}
def fileList = []
file.eachFile { fileList << it}
fileList.findAll{it.getName().endsWith('.jar')}.each { println it //getJarFileContent(it.getAbsolutePath())
}
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
import groovy.transform.*;
class User{
String name;
String email;
def toString = { " ${name} - ${email}"}
}
def user = new User(name : 'Vishnu', email: 'Vasudevan');
@visvv
visvv / ClassLoaderLeakExample.java
Created February 21, 2017 05:54 — forked from dpryden/ClassLoaderLeakExample.java
Example of a ClassLoader leak in Java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vv.test</groupId>
<artifactId>test-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
package test;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
/**
* Created by vasudvis on 10/22/2016.
*/
public class StringPermutation {
@visvv
visvv / ClientHelper.java
Created August 31, 2016 10:48 — forked from outbounder/ClientHelper.java
jersey client helper for trusting all certificates in SSL/TLS
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

public class Anagrams{
public static void main(String[] args){
boolean check = isAnagram(args[0], args[1]);
System.out.println(check);
}
public static boolean isAnagram(String str1, String str2){
if(str1.length() != str2.length()){ return false;}
int[] buffer = new int[256];
for(char ch : str1.toCharArray()){