aws --profile <profile> --region <region> ec2 describe-instances \
--filters "Name=tag-key,Values=Name" "Name=tag-value,Values=<name>" \
| jq '.Reservations[] | .Instances[] | .InstanceId'
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
/** | |
* Generate Case class from DataFrame.schema | |
* | |
* val df:DataFrame = ... | |
* | |
* val s2cc = new Schema2CaseClass | |
* import s2cc.implicit._ | |
* | |
* println(s2cc.schemaToCaseClass(df.schema, "MyClass")) | |
* |
REPL based application will fail with initialization error of REPL if its jar file name has no extension '.jar' or '.zip'.
import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.shell.{ILoop, ShellConfig}
object ReplTestMain extends App {
println("test")
val settings = new Settings
settings.usejavacp.value = true
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 test1 { | |
import com.databricks.spark.corenlp.functions._ | |
import org.apache.spark.sql.{DataFrame, SparkSession} | |
class Test(implicit spark: SparkSession) { | |
def run(df: DataFrame): DataFrame = { | |
import spark.implicits._ | |
val df2 = df.select(tokenize($"Text").as("word"), lemma($"Text").as("lemma"), pos($"Text").as("pos")).persist | |
df2.count | |
df2.unpersist() |
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 snake2camel(s:String):String = s.toList.foldLeft(List.empty[Char]){ | |
case ('_'::xs, c) => c.toUpper::xs | |
case (xs, c) => c::xs | |
}.reverse.mkString("") | |