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
// all the readers must extend this trait | |
trait Reader { | |
def read ( what: String ): DataFrame | |
} | |
object RdrFactory { | |
// could pass also a custom reader type here ... | |
def spownReader ( readerType: String , cnf: AppConfig) = { | |
readerType match { | |
case "db" => new RdrDb (cnf) |
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
// register and udf to the spark session | |
spark.sqlContext.udf.register( | |
"getRandom64CharStr", () => scala.util.Random.nextString(64)) | |
// or register and UDF accepting params | |
def getAboutTimeUDF = udf((ts: java.sql.Timestamp, timeFrame: String) => { | |
import java.util.Calendar | |
new java.sql.Timestamp( | |
timeFrame match { |
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
object InternetProtocolType extends Enumeration { | |
type InternetProtocolType = Value | |
val TCP: Value = Value("TCP") | |
val UDP: Value = Value("UDP") | |
val SCTP: Value = Value("SCTP") | |
def getProtocolType(key: String): InternetProtocolType = { |
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
val df: DataFrame = { | |
filterType match { | |
case FilterType.SqlLike => filterLikeSql(df) | |
case FilterType.XlsLike => filterLikeXls(df) | |
case _ => filterLikeSql(df) | |
} | |
} |
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
val df = spark.read | |
.format("csv") | |
.option("header", "true") | |
.load(uri) |
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 scala.collection.JavaConversions._ | |
val environmentVars = System.getenv() | |
for ((k,v) <- environmentVars) println(s"key: $k, value: $v") | |
val properties = System.getProperties() | |
for ((k,v) <- properties) println(s"key: $k, value: $v") |
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
export zeppelin_root_uri='https://company.claud.zepl.com/' | |
# issue first the call to the login | |
curl -i --data 'userName=user&password=pwd' -X POST $zeppelin_root_uri/api/login | |
# check for the | |
# Set-Cookie: JSESSIONID=b1e15e00-4171-4079-a699-338bf619b0c4; Path=/; HttpOnly | |
# line in the response header | |
curl -i -b 'JSESSIONID=b1f15e00-4571-4079-a699-338bf619b0c4; Path=/; HttpOnly' "$zeppelin_root_uri"/api/notebook |
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 scala.util.Try | |
object NumCruncher { | |
def isShort(aString: String): Boolean = Try(aString.toLong).isSuccess | |
def isInt(aString: String): Boolean = Try(aString.toInt).isSuccess | |
def isLong(aString: String): Boolean = Try(aString.toLong).isSuccess | |
def isDouble(aString: String): Boolean = Try(aString.toDouble).isSuccess | |
def isFloat(aString: String): Boolean = Try(aString.toFloat).isSuccess |
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
# | |
# ----------------------------------------------------------------------------- | |
# read dir recursively , return only the files matching the regex for the | |
# file extension , example - get all the .pl or .pm files: | |
# my $arrRefTxtFiles = $objFH->doReadDirGetFilesByExtension ( $dir, 'pl|pm') | |
# ----------------------------------------------------------------------------- | |
sub doReadDirGetFilesByExtension { | |
my $self = shift ; # remove this if you are not calling OO style | |
my $dir = shift ; | |
my $ext = shift ; |
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
:: Start - Run , type: | |
cmd /c "powershell get-date -format ^"{yyyy-MM-dd HH:mm:ss}^"|clip" | |
:: click into target media, Ctrl + V to paste the result |