Skip to content

Instantly share code, notes, and snippets.

View kannangce's full-sized avatar

Kannan Ramamoorthy kannangce

View GitHub Profile
@kannangce
kannangce / sieve-of-eratosthenes.clj
Last active April 11, 2019 12:48
Sieve of Eratosthenes in clojure
(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 March 15, 2019 05:25
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

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 August 27, 2018 10:22
A generic ResultSetExtractor to be used with Spring's JdbcTemplate for any simple beans.
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 April 3, 2024 09:11
Feign client for 1 or 2-way TLS with self signed certificates when javax.net.ssl.keyStore / javax.net.ssl.trustStore cannot be overridden.
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;