Skip to content

Instantly share code, notes, and snippets.

View visvv's full-sized avatar

Vishnu V V visvv

View GitHub Profile
@visvv
visvv / sample_http.groovy
Last active October 4, 2017 07:30
Http post request in groovy, parameters are from a properties file.
def url = new URL("http://localhost:8080/MicroFocusCA-Admin/configureACA_RunConfigTask.ajax");
def connection = url.openConnection();
connection.setRequestMethod('POST');
// set doOutput flag to true if you intend to use URL connection for Output.
connection.doOutput = true;
def properties = new Properties();
def file = new File("db_script_generate_parameters_new.properties");
// loading the properties file.
file.withInputStream {
class MessageFactory {
def static factory
def static getErrorMessage () { return factory.errorMessage }
def static getWarningMessage() { return factory.warningMessage }
def static getSuccessMessage() { return factory.successMessage }
}
def textMessageFactory = [ successMessage: "Finished successfully", errorMessage : "Finished with error", warningMessage: "Finished with warning/warnings" ]
MessageFactory.factory = textMessageFactory;
import java.util.function.*;
public class UserNameValidator{
public static void main(String[] args){
User user = new User("Vishnu");
UserValidator emptyCheck = usr -> !usr.getName().trim().isEmpty();
if(emptyCheck.apply(user)){
System.out.println(user.getName());
}else{
System.out.println("Username is empty");
import java.util.function.*;
public class FunctionCompose{
public static void main(String[] args){
System.out.println("Funaction compose");
Function<Integer, Integer> squared = a -> a * a;
Function<Integer, Integer> negated = a -> -a;
Function<Integer, Integer> squareNegated = negated.compose(squared);
System.out.println(squared.apply(12));
System.out.println(squareNegated.apply(5));
public class Outer{
private final String name = "vishnu";
private class Inner{
public Inner(){
System.out.println("Creating inner class with name " + Outer.this.name);
}
}
public static void main(String[] args){
System.out.println("Hello this is from outer");
Outer outer = new Outer();
keytool.exe -import -file ../certs/hpe-intermediate.pem -keystore /c/Program\ Files/Java/jdk1.8.0_121/jre/lib/security/cacerts
keytool.exe -import -file ../certs/david.hpeswlab.net.crt -keystore /c/Program\ Files/Java/jdk1.8.0_121/jre/lib/security/cacerts -alias david-hpeswlabs
java -cp ../../modules/system/layers/base/com/h2database/h2/main/h2-1.3.173.jar org.h2.tools.Shell -url "jdbc:h2:file:keycloak.h2.db" -user sa -password sa -sql "update REALM set ssl_required='NONE' where id = 'master'"
docker run --name postgres -e POSTGRES_DATABASE=keycloak -e POSTGRES_USER=keycloak -e POSTGRES_PASSWORD=password -e POSTGRES_ROOT_PASSWORD=password -d postgres
docker exec keycloak keycloak/bin/add-user-keycloak.sh --user admin --password admin
@visvv
visvv / ant-git.xml
Created July 12, 2017 09:17 — forked from davejlong/ant-git.xml
A simple ant script that will commit and push to a git repo.
<?xml version="1.0"?>
<project name="Demo" default="version" basedir=".">
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
@visvv
visvv / Proxy.txt
Last active February 28, 2018 05:46
Proxy
git config --global https.proxy http://proxy.xxxx.com:8080
git config --global http.proxy http://proxy.xxxx.com:8080
npm config set proxy http://proxy.xxxx.com:8080
npm config set https-proxy http://proxy.xxxx.com:8080
Properties properties = new Properties()
File propertiesFile = new File('messages.properties')
def map = [:]
propertiesFile.eachLine {
def kv = it.toString().split("=")
if(kv.size()>1){
if(map[kv[0]]){
println "existing : ${kv[0]}"
if(map[kv[0]] == kv[1]){