This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ir.iraj.ericsson; | |
import ir.iraj.ericsson.exceptions.IllegalBasePayException; | |
import ir.iraj.ericsson.exceptions.OverWorkException; | |
public class EricssonCorporation { | |
/** | |
* Minimum legal base pay | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Section 1: topic | |
# To see different options and help on a command, just run it without any parameter | |
kafka-topics | |
# To create a topic with one partition and replication factor of 1 | |
kafka-topics --zookeeper localhost:2181 --create --topic test --partitions 1 --replication-factor 1 | |
# To get a list of existing topics | |
kafka-topics --zookeeper localhost:2181 --list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
usage() { | |
echo " Register Avro schema from a file in a Schema Registry" | |
echo "" | |
echo " Usage:" | |
echo " register-avro-schema.sh <Options>" | |
echo "" | |
echo " Options:" | |
echo " -r the URL of the Schema Registry e.g. http://localhost:8081" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* How to create a database */ | |
CREATE DATABASE test_db; | |
-- Show the query in the history | |
/* If try to create a database that already exists, it fails */ | |
CREATE DATABASE test_db; | |
-- Explain the query result | |
-- Show the query in the history and that indicates the failure | |
/* In order to avoid failure in scripting, we can use IF NOT EXISTS keyword */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE fall2019_iraj; | |
-- Encoding; CSV table | |
CREATE TABLE test ( | |
name STRING, | |
age INT | |
); | |
/* Check the structure */ | |
-- Note the location | |
DESCRIBE test; |
OlderNewer