Skip to content

Instantly share code, notes, and snippets.

View skhatri's full-sized avatar

Suresh Khatri skhatri

  • Sydney, Australia
View GitHub Profile
@skhatri
skhatri / build.gradle.kts
Created June 4, 2024 13:52
java17 module permissions
plugins {
id("java")
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildscript {
@skhatri
skhatri / ca.sh
Created May 20, 2023 03:37
generate signed cert by self-signed ca
#create CA cert and self sign
if [[ ! -d ca ]];
then
mkdir ca
openssl genrsa -out ca/ca.key 2048
openssl req -new -x509 -key ca/ca.key -out ca/ca.crt -subj "/C=AU/ST=NSW/L=Sydney/O=Software Company/OU=IT/CN=ca"
fi;
cert=${1:-localhost}
@skhatri
skhatri / initdependencies.gradle
Created March 13, 2023 02:01
Init Extra Gradle Tasks
def getDependencyList(org.gradle.api.Project proj, String configName) {
def dep = []
def dd = new HashSet<String>()
proj.configurations.all { cf ->
if (cf.canBeResolved && cf.name == configName) {
cf.incoming.each { p ->
p.dependencies.each { dt ->
dd.add("$dt.group:$dt.name:$dt.version".toString())
dep << [group: dt.group, name: dt.name, version: dt.version, transitive: false]
}
@skhatri
skhatri / PokemonSolr.cql
Last active February 1, 2023 23:18
Pokemon Solr with CQL
create keyspace pokedex with replication = {
'class': 'NetworkTopologyStrategy',
'dc1': 1
};
drop table if exists pokedex.pokemons;
create table pokedex.pokemons(
name text,
primary_type text,
@skhatri
skhatri / tasks.gradle
Created October 16, 2022 02:14
gradle dependency printer
gradle.taskGraph.whenReady { tg ->
configurations.all { cf ->
if (cf.canBeResolved && cf.name == "runtimeClasspath") {
cf.incoming.each { p ->
println(p.name)
//resolved artifact dependency
p.artifacts.each { at ->
println(at.id.componentIdentifier)
}
//direct dependency
@skhatri
skhatri / WordCount.md
Created September 27, 2022 02:59
WordCount Apache Spark

With RDD

    val sc = new SparkContext(new SparkConf()
                                .setAppName("word-count-rdd").setMaster("local[1]")
                                .set("spark.driver.ip", "127.0.0.1")
            )

    sc.textFile(path).flatMap(line => line.toLowerCase().split(" "))
    .map(w => (w, 1))
    .reduceByKey((v1, v2) => v1 + v2)
@skhatri
skhatri / value_of_pi.go
Created August 7, 2022 11:24
value of pi
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
@skhatri
skhatri / Dockerfile_tensorflow
Created August 1, 2020 10:44
Latest Tensorflow with sklearn
FROM tensorflow/tensorflow:latest-gpu-jupyter
RUN python3 -m pip install --upgrade pip && pip3 install graphviz pandas sklearn && echo '{"NotebookApp": {"nbserver_extensions": {"jupyter_http_over_ws": true},"password": "sha1:92cf1ff5134d:eecd093c46b3b5b98285ab0238ebe929e640b2a8"}}' |tee /root/.jupyter/jupyter_notebook_config.json
@skhatri
skhatri / Dockerfile
Created June 24, 2020 12:38
alpine docker zulu java11 microservices
FROM azul/zulu-openjdk-alpine:11.0.7
LABEL base=alpine engine=jvm version=java11 timezone=UTC port=8080 dir=/opt/app user=app
RUN apk update && apk add --no-cache tzdata curl bash && rm -rf /var/cache/apk/*
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
EXPOSE 8080
RUN mkdir -p /opt/app && ln -s /opt/app /lib
@skhatri
skhatri / Dockerfile
Created June 24, 2020 12:38
ubi minimal docker java11 microservices
FROM registry.access.redhat.com/ubi8/ubi-minimal
LABEL base=ubi8 engine=jvm version=java11 timezone=UTC port=8080 dir=/opt/app user=app
RUN microdnf install java-11-openjdk-headless openssl hostname bash curl tzdata shadow-utils && microdnf clean all
ENV JAVA_HOME=/usr/lib/jvm/jre-11
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
EXPOSE 8080