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 MyFancyErrCode extends Enumeration { | |
type MyFanceErrCode = Value | |
val NO_FILE: Value = Value | |
val NO_DIR: Value = Value | |
} | |
case class MyFancyCustomException1(val errCode :MyFancyErrCode , msg: String) extends Exception(msg) | |
case class MyFancyCustomException2(val errCode :MyFancyErrCode , msg: String) extends Exception(msg) | |
case class TotallyUnknownException(msg: String) extends Exception(msg) |
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-many forward or backward slashes are there | |
$rel_levels++ while ($relative_path =~ m/[\/\\]/g); |
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
def genDummyDf(): DataFrame = { | |
spark | |
.createDataFrame( | |
spark.sparkContext.parallelize( | |
Seq( | |
Row("foo") | |
)), | |
StructType( | |
Seq( | |
StructField("bar", StringType) |
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 list all the files and dir in a dir sorted by their | |
# modified time in the different shells | |
# usually mac os / Unix / FreeBSD stat | |
stat -f "%Sm %N" -t "%Y-%m-%d %H:%M:%S" ~/opt/comp/proj/*|sort | |
# STDOUT output: | |
# 2018-03-27 15:41:13 ~/opt/comp/proj/foo | |
# 2018-03-28 14:04:11 ~/opt/comp/proj/bar | |
# GNU Utils ( usually on Linux ) stat |
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
curr_branch=$(git rev-parse --abbrev-ref HEAD); git branch "$curr_branch"--$(date "+%Y%m%d_%H%M"); git branch -a | grep $curr_branch | sort -nr | less |
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
(1 to 100).foreach(n => { | |
println ( "n: " + n.toString() ) | |
}) |
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.hadoop.fs.{FileSystem, Path} | |
trait HavingSparkSession { | |
implicit val spark: SparkSession = SparkSession.builder().getOrCreate() | |
} | |
object HdfsPathUtils extends HavingSparkSession { | |
def pathExists(path: String): Boolean = { | |
val spark: SparkSession = SparkSession.builder().getOrCreate() | |
val conf = spark.sparkContext.hadoopConfiguration |
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 you need to know about log levels src: https://i.stack.imgur.com/Z5mag.png --> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" /> | |
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> | |
<encoder> | |
<pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%level] %msg %n</pattern> | |
</encoder> | |
</appender> |
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
# str-kebab-case -> strKebapCase | |
$str =~ s/(?<=[^\W\-])\-([^\W\-])|([^\W\-]+)|\-/\U$1\L$2/g ; |
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
# works on allmost any OS with perl ... because ... perl rulez !!! | |
script_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0") |