Skip to content

Instantly share code, notes, and snippets.

View saswata-dutta's full-sized avatar
💭
I may be slow to respond.

Saswata Dutta saswata-dutta

💭
I may be slow to respond.
View GitHub Profile
@saswata-dutta
saswata-dutta / Schema2CaseClass.scala
Created October 24, 2020 08:18 — forked from yoyama/Schema2CaseClass.scala
Generate case class from spark DataFrame/Dataset schema.
/**
* Generate Case class from DataFrame.schema
*
* val df:DataFrame = ...
*
* val s2cc = new Schema2CaseClass
* import s2cc.implicit._
*
* println(s2cc.schemaToCaseClass(df.schema, "MyClass"))
*
@saswata-dutta
saswata-dutta / CacheConfig.java
Created September 17, 2020 10:30 — forked from anataliocs/CacheConfig.java
Guava cache with spring boot and clear cache method
import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCache;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
@saswata-dutta
saswata-dutta / DataFrameTesting.scala
Created September 8, 2020 11:45 — forked from andfanilo/DataFrameTesting.scala
An implementation of DataFrame comparison functions from spark-testing-base's DataFrameSuiteBase trait in specs2
package utils
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.types.StructType
import org.apache.spark.sql.{DataFrame, Row}
import org.specs2.matcher.{Expectable, Matcher}
import org.specs2.mutable.Specification
/**
* Utility class to compare DataFrames and Rows inside unit tests
@saswata-dutta
saswata-dutta / gist:5ff1f32a8be41029eac47326f5bca5d5
Created August 24, 2020 12:33 — forked from MHawksworth/gist:2700832
Getting DBUnit to play nice with Hibernate hbm2ddl.auto database changes by extending DBTestCase
package com.ossAccounts.ac.server;
import java.io.FileInputStream;
import org.dbunit.DBTestCase;
import org.dbunit.IDatabaseTester;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
import org.dbunit.ext.mssql.InsertIdentityOperation;
import org.dbunit.operation.DatabaseOperation;
import org.hibernate.Session;
@saswata-dutta
saswata-dutta / CallerBlocksPolicy.java
Created August 4, 2020 10:10 — forked from jexp/CallerBlocksPolicy.java
CallerBlocksPolicy as alternative to CallerRunsPolicy if the calling thread and the pool threads(tasks) share a similar thread local which would then be messed up.
public static ExecutorService createDefaultPool() {
int threads = Runtime.getRuntime().availableProcessors()*2;
int queueSize = threads * 25;
return new ThreadPoolExecutor(threads / 2, threads, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(queueSize),
new CallerBlocksPolicy());
// new ThreadPoolExecutor.CallerRunsPolicy());
}
static class CallerBlocksPolicy implements RejectedExecutionHandler {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
@saswata-dutta
saswata-dutta / gremlin-cheat-sheet.md
Created August 1, 2020 16:21 — forked from jeremysears/gremlin-cheat-sheet.md
Gremlin Cheat Sheet in Groovy

Gremlin Cheat Sheet in Groovy

Gremin traversal examples taken from the excellent DS330: DataStax Enterprise Graph course.

Creating Vertices and Vertex Properties

Add a Vertex

Vertex u = graph.addVertex("user");
       u.property("userId","u2016");
 u.property("age",36);
original on :https://www.webslesson.info/2018/09/insert-tree-view-node-using-php-ajax.html
http://www.techsapphire.in/index/grandparent_parent_and_child_hierarchy_sql_server_or_bread_crumb/0-170
https://www.youtube.com/watch?v=RswtHsz4v-0
https://www.ruvictor.com/article/php-recursive-functions
<?php
//fetch.php
include('database_connection.php');
@saswata-dutta
saswata-dutta / emrfs.md
Created July 16, 2020 19:23 — forked from snigdhasjg/emrfs.md
Getting started with EMRFS.

Getting started with EMRFS

The EMR File System (EMRFS) is an implementation of HDFS that all Amazon EMR clusters use for reading and writing regular files from Amazon EMR directly to Amazon S3.

How to access a file from S3 using EMRFS

Using Java

Coming from HDFS it is very easy to implement EMRFS. You just need to pass URI("s3://<bucket-name>") object while getting filesystem object.

package com.joe;
@saswata-dutta
saswata-dutta / Create a cluster
Created July 16, 2020 19:23 — forked from BeatriceMoissinac/Create a cluster
[AWS EMR] How to create and manage clusters on AWS EMR #AWS
// vim: syntax=shell
$JAR=/usr/lib/spark/lib/spark-examples.jar
$KEY=MoissinB
# Create cluster with 1st step
aws emr create-cluster --profile $KEY \
--name "Moissinb Cluster" \
--release-label emr-5.10.0 \
--applications Name=Spark \
@saswata-dutta
saswata-dutta / Selections-Sublime.md
Created July 10, 2020 06:55 — forked from dufferzafar/Selections-Sublime.md
Selections and Multiple Cursors in Sublime Text 3

Selections and Multiple Cursors in Sublime Text 3

A handy list of selection shortcuts.

Here are the official docs: Keyboard and Mouse

Mouse

Building blocks:

  • Add to selection: Ctrl
  • Subtract from selection: Alt