Skip to content

Instantly share code, notes, and snippets.

@dhval
dhval / trustSsl.java
Created August 2, 2023 13:40
Add SSL
import javax.net.ssl.*;
import java.io.*;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public class Test {
private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray();
@dhval
dhval / 0ReadMe.md
Last active November 14, 2021 17:32
Java Practice

Some Random Code Snippets

function FindProxyForURL(url, host) {
PROXY = "SOCKS5 127.0.0.1:9743; SOCKS 127.0.0.1:9743"
// PROXY = "PROXY 127.0.0.1:9743"
// "PROXY 127.0.0.1:23870";
alert("ABCXY request for (" + url+ " with host: " + host + ")");
if(shExpMatch(url, "http://10.182.70.240*"))
return PROXY;
}
@dhval
dhval / API.md
Last active February 11, 2022 15:00
Java/CSharp API reference

|--- Strings |--- Char

*** String is immutable so they do not have method like reverse.

  • .toCharArray()
  • .split()
@dhval
dhval / Application.java
Last active January 29, 2021 18:48
Spring Boot Web Service Provider (clean)
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
@SpringBootApplication
@EnableWs
@dhval
dhval / .0READMW.md
Last active September 15, 2021 18:25
Shell Scripts Snippets
  • She bang line, location of shell which bash
  • Store arguments from bash in array args=("$@")
  • Number of arguments count=("$#")
  • Date NOW=$(date +"%m-%d-%Y")
  • Print a random file files=(./*); printf "%s\n" "${files[RANDOM % ${#files[@]}]}"
  • Create empty dir [ -d "./data" ] && mkdir data || rm -rf ./data/*

Iteration

Moves selected files

@dhval
dhval / ReadExcelToJson.java
Last active May 3, 2024 13:57
Convert Excel to JSON
#!/usr/bin/java --source 12 --class-path /Users/dhval/project/jar/poi-3.16/lib/*
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
@dhval
dhval / docker:Dockerfile
Created December 20, 2015 20:48
Java Docker Template
From ubuntu
MAINTAINER Dhval Mudawal
RUN apt-get update && apt-get --ignore-missing install -y \
build-essential \
lsof \
git \
wget \
software-properties-common \
&& apt-get clean
@dhval
dhval / Linux Static IP
Created November 4, 2015 15:18 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static