Skip to content

Instantly share code, notes, and snippets.

View vishalg0wda's full-sized avatar

Vishal Gowda vishalg0wda

  • Lacework
  • London, UK
View GitHub Profile
@vishalg0wda
vishalg0wda / index.html
Created June 20, 2025 14:05
primary<>java25-refresh test changes
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Diff to HTML by rtfpessoa</title>
<!--
Diff to HTML (template.html)
Author: rtfpessoa
-->
@vishalg0wda
vishalg0wda / diff.txt
Created June 20, 2025 14:05
primary<>java25-refresh test changes
diff '--color=auto' -ruNwB templates/templates/javav2/tests/primary/ErrorAdditionalTest.java templates/templates/javav2/tests/java25-refresh/ErrorAdditionalTest.java
--- templates/templates/javav2/tests/primary/ErrorAdditionalTest.java 2025-04-17 14:07:58.172680312 +0100
+++ templates/templates/javav2/tests/java25-refresh/ErrorAdditionalTest.java 2025-06-20 12:44:23.793115199 +0100
@@ -5,8 +5,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.Optional;
-
import org.junit.jupiter.api.Test;
@vishalg0wda
vishalg0wda / multicast-channels.rs
Created December 9, 2024 21:00
Illustrating SPMC(randomized consumer selection)
use rand::prelude::SliceRandom;
use rand::random;
use std::fmt::Debug;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use tokio::sync::oneshot;
use tracing::{info, instrument, span, trace, Level};
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
@vishalg0wda
vishalg0wda / ping-pong.rs
Created December 2, 2024 15:37
R/w of newline delimited messages over a TCP Socket in Rust
use std::io::{BufRead, BufReader, BufWriter, Read, Write};
use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream};
fn server(addr: SocketAddr) {
let listener = TcpListener::bind(addr).unwrap();
let (con, _) = listener.accept().unwrap();
let reader = BufReader::new(&con);
let mut writer = BufWriter::new(&con);
for msg in reader.lines() {
let Ok(msg) = msg else {
@vishalg0wda
vishalg0wda / PayNotificationListener.java
Last active July 16, 2021 10:07
Composite annotation that applies required property overrides and proxies other commonly used parameters to meta annotations.
package com.booking.payments.point.common.core.annotation;
import com.booking.payments.point.common.core.model.MetricNames;
import io.micrometer.core.annotation.Timed;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.beans.factory.annotation.Qualifier;
class Solution {
public int[][] merge(int[][] intervals) {
Map<Integer, Integer> intervalMap = new HashMap<>();
for (int[] interval: intervals) {
intervalMap.putIfAbsent(interval[0], 0);
intervalMap.compute(interval[0], (k, v) -> v > interval[1] ? v : interval[1]);
}
Map<Integer, Integer> merged = new HashMap<>();
List<Integer[]> out = new LinkedList<>();
int minStart = -1, maxEnd = -1;
@vishalg0wda
vishalg0wda / FindWord.java
Created June 6, 2021 10:16
FindWord.java
class Solution {
public boolean exist(char[][] board, String word) {
if (word == null || word.length() == 0) return true;
boolean[][] visited = new boolean[board.length][board.length];
Character startChar = word.charAt(0);
for (int r = 0; r < board.length; r++) {
for (int c = 0; c < board.length; c++) {
visited[r][c] = true;
if (board[r][c] == startChar && backtracking(1, r, c, visited, board, word)) return true;
visited[r][c] = false;
@vishalg0wda
vishalg0wda / rotting-oranges.py
Last active May 8, 2021 12:12
Rotting Oranges
from collections import deque
class Solution:
def __init__(self):
self.grid = None
self.rows = 0
self.cols = 0
def bfs(self, rottens: list[tuple[int]]) -> int:
q = deque([(rr, rc, 0) for (rr, rc) in rottens])
minutes = 0
@vishalg0wda
vishalg0wda / knights_probability.py
Created March 28, 2021 21:29
knights_probability - OS
class Solution:
def knightProbability(self, N: int, K: int, r: int, c: int) -> float:
moves = [(-2, 1), (-2, -1), (-1, 2), (-1, -2), (1, 2), (1, -2), (2, 1), (2, -1)]
dp0 = [[1] * N for _ in range(N)]
to_visit = {(r, c)}
count = 0
for _ in range(K):
dp1 = [[0] * N for _ in range(N)]
new_to_visit = set()
for (r, c) in to_visit:
@vishalg0wda
vishalg0wda / knight_probability.py
Created March 28, 2021 11:47
knight-probability-in-chessboard (BF)
def knightProbability(self, N: int, K: int, r: int, c: int) -> float:
grid = [[0] * N for _ in range(N)]
# utility to count number of moves given a starting position
def recur(r: int, c: int, k: int) -> int:
if not (0 <= r < N and 0 <= c < N):
return 0
if k == 0:
return 1
# try all 8 possible moves
return (