Skip to content

Instantly share code, notes, and snippets.

@MaherBhasvar
MaherBhasvar / ArrayExample3.scala
Created December 17, 2021 15:33
Calculate sum of array of Int using UDF in Spark-Scala
def main (args: Array[String]) : Unit = {
val spark = SparkSession
.builder
.appName("Temp")
.config("spark.master", "local")
.getOrCreate
val sumArray = udf((vs: Seq[Int]) => vs match {
case _ => {
var sum = 0
@MaherBhasvar
MaherBhasvar / ArrayExample2.scala
Created December 17, 2021 14:09
UDF i.e. User Defined Functions is a very helpful API from Spark SQL. It acts as a column based function. One of the important case I used it, is for converting complex data structure like arrays and structs to String, the reason being, I wanted to save the data in a csv, and saving in csv wont go through with these data structures.
def main (args: Array[String]) : Unit = {
val spark = SparkSession
.builder
.appName("Temp")
.config("spark.master", "local")
.getOrCreate
val stringifyArray = udf(( vs: Seq[Int]) => vs match {
case null => null
case _ => s"${vs.mkString(" ")}"
@MaherBhasvar
MaherBhasvar / ArrayExample1.scala
Created December 17, 2021 14:03
UDF i.e. User Defined Functions is a very helpful API from Spark SQL. It acts as a column based function. One of the important case I used it, is for converting complex data structure like arrays and structs to String, the reason being, I wanted to save the data in a csv, and saving in csv wont go through with these data structures.
def main (args: Array[String]) : Unit = {
val spark = SparkSession
.builder
.appName("Temp")
.config("spark.master", "local")
.getOrCreate
val stringifyArray = udf(( vs: Seq[String]) => vs match {
case null => null
case _ => s"${vs.mkString(" ")}"
@MaherBhasvar
MaherBhasvar / Redux.js
Created August 20, 2019 19:47
Pure redux, just for understanding purpose
console.clear()
//action creators
const newPolicy = (name, amount) => {
return {
type: "NEW_POLICY",
payload: {name: name, amount: amount}
}
}
@MaherBhasvar
MaherBhasvar / ViewController.swift
Last active July 30, 2019 08:06
Putting Circular tiles to display and choose numbers Part-4
//
// ViewController.swift
// Practice-Adding-Numbers
//
// Created by Maher Bhavsar on 29/07/19.
// Copyright © 2019 Seven Dots. All rights reserved.
//
import UIKit
import SceneKit
@MaherBhasvar
MaherBhasvar / ViewController.swift
Created July 29, 2019 20:40
Putting Circular tiles to display and choose numbers Part-3
//
// ViewController.swift
// Practice-Adding-Numbers
//
// Created by Maher Bhavsar on 29/07/19.
// Copyright © 2019 Seven Dots. All rights reserved.
//
import UIKit
import SceneKit
@MaherBhasvar
MaherBhasvar / ViewController.swift
Created July 29, 2019 20:31
Putting Circular tiles to display and choose numbers Part-2
//
// ViewController.swift
// Practice-Adding-Numbers
//
// Created by Maher Bhavsar on 29/07/19.
// Copyright © 2019 Seven Dots. All rights reserved.
//
import UIKit
import SceneKit
@MaherBhasvar
MaherBhasvar / ViewController.swift
Created July 29, 2019 08:21
Putting Circular tiles to display and choose numbers Part-1
//
// ViewController.swift
// Practice-Adding-Numbers
//
// Created by Maher Bhavsar on 29/07/19.
// Copyright © 2019 Seven Dots. All rights reserved.
//
import UIKit
import SceneKit
@MaherBhasvar
MaherBhasvar / ViewController.swift
Created July 26, 2019 19:02
Placing Virtual Object through Center of the Screen Made using ARKit in iOS
//
// ViewController.swift
// Practice-Adding-Plane
//
// Created by Maher Bhavsar on 25/07/19.
// Copyright © 2019 Seven Dots. All rights reserved.
//
import UIKit
import SceneKit
@MaherBhasvar
MaherBhasvar / ViewController.swift
Created July 25, 2019 20:47
Adding Virtual Objects on Planes in Augmented Reality, made with ARKit in Swift
//
// ViewController.swift
// Practice-Adding-Plane
//
// Created by Maher Bhavsar on 25/07/19.
// Copyright © 2019 Seven Dots. All rights reserved.
//
import UIKit
import SceneKit