Skip to content

Instantly share code, notes, and snippets.

View irajhedayati's full-sized avatar

Iraj Hedayati irajhedayati

View GitHub Profile
@irajhedayati
irajhedayati / resultset-iteartor.scala
Last active November 19, 2020 21:48
Scala cheatsheet
// How to convert a JDBC iterator to a Scala iterator
/* A data model to reflect the content of ResultSet */
case class Movie(mId: Int, title: String, rId: Int, ratingDate: String)
import java.sql.{ ResultSet, Statement }
val stmt: Statement = ???
val rs: ResultSet = statement.executeUpdate("SELECT * FROM movie".stripMargin)
@irajhedayati
irajhedayati / logger.sh
Created November 10, 2020 15:33
A simple library in implementing bash scripts
#!/usr/bin/env bash
if [[ -f /etc/lsb-release ]]; then
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
NO_COLOUR=$(tput sgr0)
else
RED="\033[91m"
GREEN="\033[92m"
@irajhedayati
irajhedayati / setup.sh
Last active September 9, 2020 13:13
MCIT VM preparation
# Install SSH on the machine
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
# Create a new user
sudo useradd -m -d /home/iraj/ -s /bin/bash -G sudo iraj
sudo passwd iraj
## pick a password
@irajhedayati
irajhedayati / raining.csv
Last active August 25, 2020 20:33
Data engineering course datasets
month rainfall umbrellas_sold
Jan 82 15
Feb 92.5 25
Mar 83.2 17
Apr 97.7 28
May 131.9 41
Jun 141.3 47
Jul 165.4 50
Aug 140 46
Sep 126.7 37
@irajhedayati
irajhedayati / cassandra-as-rdd-spark-sehll.scala
Last active August 13, 2020 20:20
Deploy a local multi-node Cassandra cluster using Docker
/*
Run Spark shell using spark-shell --packages datastax:spark-cassandra-connector:2.4.0-s_2.11 command
Check the versions compatibility on https://github.com/datastax/spark-cassandra-connector#version-compatibility
*/
import com.datastax.spark.connector._
import org.apache.spark.sql._
val spark = SparkSession.builder().
appName("Spark SQL practice").master("local[*]").
config("spark.cassandra.connection.host", "localhost").
@irajhedayati
irajhedayati / EricssonCorporation.java
Last active January 4, 2016 00:34
Ericsson Corporation
package ir.iraj.ericsson;
import ir.iraj.ericsson.exceptions.IllegalBasePayException;
import ir.iraj.ericsson.exceptions.OverWorkException;
public class EricssonCorporation {
/**
* Minimum legal base pay
*/