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 object mail { | |
implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
sealed abstract class MailType | |
case object Plain extends MailType | |
case object Rich extends MailType | |
case object MultiPart extends MailType |
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
import java.time.format.DateTimeFormatter | |
import java.time.LocalDateTime | |
import java.time.ZoneId | |
val ny = ZoneId.of("America/New_York") | |
val utc = ZoneId.of("UTC") | |
val dateTime = LocalDateTime.now.atZone(utc) | |
val nyTime = DateTimeFormatter. | |
ofPattern("yyyy-MMM-dd HH:mm z"). |
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
import org.apache.spark.sql.functions._ | |
import org.apache.spark.sql.Row | |
import spark.implicits | |
import org.apache.spark.sql.functions.udf | |
// https://stackoverflow.com/questions/55083109/how-to-get-min-and-max-value-from-multiple-columns-in-a-dataframe-in-spark | |
// assumes the first column is an index and probably a string, but all other columns are integers. | |
val df = Seq( | |
("r0", 0, 2, 3), |
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
// ------------------------------------------------------------- | |
// spark/scala | |
// ------------------------------------------------------------- | |
//union a dataframe and return the records that a are different | |
val diff = df.union(df2).except(df)) | |
// ------------------------------------------------------------- | |
//udf for turning empty dataframe cells into null dataframe cells |
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
import spark.implicits | |
val df = Seq( | |
("bravo", "southern charm", "b-sc-first-episode", true, false, 5, 10), | |
("bravo", "southern charm", "b-sc-second-episode", false, false, 11, 22), | |
("bravo", "vanderpump", "b-v-first-episode", true, false, 3, 6), | |
("bravo", "vanderpump", "b-v-second-episode", false,false, 4, 8), | |
("syfy", "krypton", "s-kr-first-episode", false, true, 2, 4), | |
("syfy", "below deck", "s-bd-first-episode", true, true, 1, 2) | |
).toDF("network_name", "show_name", "episode", "in_scope", "supported", "completes", "views"). |
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 from spark shell | |
// you'd probably never do this, but just in case you ever wanted to. | |
import scala.io.Source | |
import spark.implicits | |
val url = "https://raw.githubusercontent.com/sitepoint-editors/json-examples/master/src/db.json" | |
val json = Source. | |
fromURL(url). |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"s3:ListAllMyBuckets", | |
"s3:GetBucketLocation" | |
], | |
"Effect": "Allow", | |
"Resource": [ |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"s3:ListAllMyBuckets", | |
"s3:GetBucketLocation" | |
], | |
"Effect": "Allow", | |
"Resource": [ |
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
// scala-and-spark-for-big-data-and-machine-learning | |
//Section 8 lesson 33 | |
//Find out if you have all even numbers in a list. | |
List(0, 2, 4). | |
map(_%2).sum == 0 | |
//Lucky number 7 card problem, Add your cards, but double 7 if you get it. | |
List(0, 2, 5, 7). |
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
# Get your files ignored correctly on the file system and website, keep checking until | |
# the latest commit is perfect. | |
639 vi ./.gitignore | |
640 git rm -r --cached . | |
641 git add -A | |
642 git commit -m "adding" | |
643 git push origin master | |
# now create a temp branch off master, then delete the master, and push master back up again. |
OlderNewer