Skip to content

Instantly share code, notes, and snippets.

Kannan Ramamoorthy kannangce

Block or report user

Report or block kannangce

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kannangce
kannangce / FomatConverter.java
Created Oct 15, 2019
Java utility to apply a transformation on the matched patterns in a given string.
View FomatConverter.java
public class FomatConverter{
/**
* Searches the given pattern in the given src string and applies the txr to the
* matches
*
* @param src The string to be converted
* @param pattern the pattern for which the transformers to be applied.
* @param txr The transformers for the mathed patterns.
* @return The result after applying the transformation.
*/
@kannangce
kannangce / RespectSigPipe.java
Created Oct 1, 2019
Showcase on capturing and making use of SIG_PIPE
View RespectSigPipe.java
import sun.misc.Signal;
import sun.misc.SignalHandler;
/**
* Demo on making use of SIG_PIPE
*
*/
public class RespectSigPipe
{
static boolean isPipeRecieved = false;
@kannangce
kannangce / custom-comp.clj
Created May 4, 2019
Custom implementation of clojure 'comp'.
View custom-comp.clj
(defn custom-comp
"Custom implementation of clojure 'comp'.
Accepts a set of functions and returns a composite of
those functions.
ex, ((custom-comp f1 f2 f3) some-argument) = (f1(f2(f3(some-argument))))"
[& fns]
(fn [& params]
(loop [fn-list fns
@kannangce
kannangce / sieve-of-eratosthenes.clj
Last active Apr 11, 2019
Sieve of Eratosthenes in clojure
View sieve-of-eratosthenes.clj
(defn multiple?
"Check if the number-to-check is a multiple of number."
[number-to-check number]
(= 0 (mod number-to-check number)))
(defn sieve-of-eratosthenes
"For the number ranging from 2 to the given number 'upto'(inclusive),
filters out all the numbers that are not prime and
return the prime numbers."
[upto]
@kannangce
kannangce / Command Line utils.adoc
Last active Mar 15, 2019
Contains quick command line utils that will be required for some scenarios that I faced. Some times the equivalent site I used is also mentioned
View Command Line utils.adoc

Start all the docker containers

docker ps -a|tail -n +2|awk '{print $1}'|xargs docker start

Diff

This gives side-by-side diff.

diff -y file_1 file_2

@kannangce
kannangce / GenericResultSetExtractor.java
Created Aug 27, 2018
A generic ResultSetExtractor to be used with Spring's JdbcTemplate for any simple beans.
View GenericResultSetExtractor.java
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import org.springframework.dao.DataAccessException;
@kannangce
kannangce / FeignSSLUtils.java
Last active Mar 3, 2020
Feign client for 1 or 2-way TLS with self signed certificates when javax.net.ssl.keyStore / javax.net.ssl.trustStore cannot be overridden.
View FeignSSLUtils.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.AccessController;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
You can’t perform that action at this time.