Skip to content

Instantly share code, notes, and snippets.

View GopinathMR's full-sized avatar

Gopinath Rangappa GopinathMR

View GitHub Profile
@GopinathMR
GopinathMR / LeetCodeSolution523.java
Created May 28, 2025 22:30
leetcode 523 : handling zeros correctly
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Default solution you find in youtube won't work for [4, 1, 0] , k = 3. So, we need to add extra check for
* this corner case.
* Test cases 4, 5 and 6 pose interesting scenario because of 0s.
@GopinathMR
GopinathMR / Solution_1249_Variant.java
Last active May 28, 2025 22:28
Leetcode 1249 variant which should also cover different paranthesis types and matching should be based on the paranthesis type
// leet code 1249 variant
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import org.apache.commons.lang3.tuple.Pair;
@GopinathMR
GopinathMR / json-schema2athena.sh
Last active June 29, 2017 04:20
json-schema to AWS Athena bulk column format
#!/bin/bash
# $1 is json-schema file path
cat $1 | jq ".properties | to_entries[] | (.key + \" \" + .value.type)" | sed -e "s/integer/int/g" | sed -e "s/ \"$/ string\"/g" | sed -e "s/\"//g" | sed -e "s/$/,/g"
@GopinathMR
GopinathMR / NonLazySingleton.java
Last active April 20, 2021 08:45
how to mock methods in Singleton
// sample code written to showcase how to use Mockito to mock certain methods to test logic in Singleton classes
public class MySingletonClass {
// not lazy initiated object.
private static final MySingeltonClass INSTANCE = new MySingletonClass();
// can be used by unit test by Mocking it. Mockito invokes this default constructor.
@VisibleForTesting
MySingletonClass {
http://eclipsecolorthemes.org/?view=theme&id=22933
#!/bin/sh
#
# This hook will run the eclipse code formatter before any commit
# to make the source look as it's supposed to look like in the repo.
ECLIPSE_HOME=$HOME/eclipse
STYLE_FILE=$HOME/org.eclipse.jdt.core.prefs
echo "Running pre-commit hook: run-eclipse-formatter---------------------"
echo "Will run eclipse formatter, using: $STYLE_FILE"
echo "Listing folders to run formatter on… "
@GopinathMR
GopinathMR / emacs-hotkey-setup.txt
Last active December 19, 2015 13:18
emacs hotkey setup
Install auto-hotkey on windows from http://www.autohotkey.com/
Load script file with extension .ahk , containing belowl lines. This will swap caps lock and left ctrl key.
CapsLock::Ctrl
LCtrl::CapsLock
Load script, you are done :)
@GopinathMR
GopinathMR / _gvimrc
Last active January 16, 2024 12:29
GVim config file (for both Windows and Unix)
" Gopi's _gvimrc file https://github.com/GopinathMR
" This file has been modified to make it work on both Windows and Linux
" Github gist location : https://gist.github.com/1100054
" If you find any issues or add any enhancements, please submit revised version as gist
"----------------------------------------------------------------------------------------------------------
" 1. OS specific
if ($OS == 'Windows_NT')
" Windows specific settings