Skip to content

Instantly share code, notes, and snippets.

View svkrclg's full-sized avatar
🏠
Working from home

Sk svkrclg

🏠
Working from home
View GitHub Profile
@svkrclg
svkrclg / having-multiple-jdk-macos.md
Created September 12, 2024 18:09 — forked from gramcha/having-multiple-jdk-macos.md
Managing multiple Java versions in MacOS

Installing different versions of open jdk through Homebrew(assuming already installed) and already having Java 8.

We need to install a tool called jenv - Java version manager which is similar to nvm(nodeJs version manager).

brew install jenv

Export the jenv path to .bash_profile or .zshrc - whatever you are using. I am using .zshrc

@svkrclg
svkrclg / grpc-server-hsvc.yaml
Last active January 28, 2023 11:30
GRPC server headless service
apiVersion: v1
kind: Service
metadata:
name: grpc-server
namespace: default
spec:
type: ClusterIP
clusterIP: None
selector:
application: envoy
@svkrclg
svkrclg / envoy-hsvc.yaml
Created January 28, 2023 11:08
envoy headless service
apiVersion: v1
kind: Service
metadata:
name: envoy-hsvc
namespace: default
spec:
type: ClusterIP
clusterIP: None
selector:
application: envoy
@svkrclg
svkrclg / envoy-deployment.yaml
Created January 28, 2023 11:06
Envoy k8s deployment
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
application: envoy
name: envoy
namespace: default
spec:
replicas: 2
strategy:
@svkrclg
svkrclg / process_post.txt
Last active December 19, 2021 17:37
procees POST packet
public String[] processData(String request) {
String lines[] = request.split("\r\n");
int cl = -1;
for(String line : lines) {
System.out.println(line);
if(line.contains("Content-Length")) {
String x = line.substring(16);
cl = Integer.parseInt(x);
break;
}
@svkrclg
svkrclg / post_endpoint.txt
Last active December 19, 2021 17:27
POST read and send response
String dataString = "";
String body = "";
try
{
while(true)
{
int bytesRead = in.read(messageByte);
if (bytesRead == -1)
break;
dataString += new String(messageByte, 0, bytesRead);
@svkrclg
svkrclg / send_response.txt
Last active December 19, 2021 16:58
frame HTTP response
// Get output stream
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
String message = "HTTP/1.1 200 OK\r\n" +
"Server: noob-server\r\n" +
"Date: 14 March, 1977\r\n" +
"\r\n" +
"Hello world - noob server";
out.write(message.getBytes());
@svkrclg
svkrclg / read_get_packet_snippet.txt
Last active December 18, 2021 15:56
Parse Get endpoint
socket = server.accept();
System.out.println("Client accepted");
DataInputStream in = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
byte[] messageByte = new byte[1000];
String dataString = "";
while(true)
{
int bytesRead = in.read(messageByte);
@svkrclg
svkrclg / server.java
Created November 7, 2021 16:23
A Java program to liste TCP connection
ServerSocket server = new ServerSocket(80); // Listen for connection on port 89
System.out.println("Server started");
Socket socket = server.accept(); //Wait for client
System.out.println("Client accepted");
@svkrclg
svkrclg / urls.txt
Last active February 19, 2021 08:49
let url = [
"csdn.net",
"github.com",
"canva.com",
"yahoo.co.jp",
"naver.com",
"bongacams.com",
"bing.com",
"ebay.com",
"yy.com",