Skip to content

Instantly share code, notes, and snippets.

View jesusjavierdediego's full-sized avatar

Jesus de Diego jesusjavierdediego

View GitHub Profile
import java.util.Map.Entry
import com.typesafe.config.{ConfigFactory, ConfigObject, ConfigValue}
import scala.collection.JavaConverters._
import scala.util.Properties
class Configuration(fileNameOption: Option[String] = None) {
val config = fileNameOption.fold(ifEmpty = ConfigFactory.load())(file => ConfigFactory.load(file) )
def envOrElseConfig(name: String): String = {
@jesusjavierdediego
jesusjavierdediego / Dockerfile
Created October 22, 2018 14:46
Go-Dockerfile
FROM golang:1.10 AS build-image
ADD https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep
WORKDIR $GOPATH/src/fts/STSCardValidator
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure --vendor-only
COPY . ./
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fts.cp</groupId>
<artifactId>bpmn-ui</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>bpmn-ui</name>
<url>https://gitlab-delivery-platform.fexcofts.com/cp/bpmn-ui</url>
<properties>
def getListOfDiagramFilesFromDirectory(dir: String): Array[Option[Elem]] = {
val canonicalPath = getClass.getResource("/".concat(dir))
var listOfFiles: ArrayBuffer[Option[Elem]] = ArrayBuffer[Option[Elem]]()
if (canonicalPath.getProtocol().equals("jar")) {
val jarPath: String = canonicalPath.getPath().substring(5, canonicalPath.getPath().indexOf("!"))
val jar: JarFile = new JarFile(URLDecoder.decode(jarPath, "UTF-8"))
val entries = jar.entries()
while(entries.hasMoreElements){
val entry = entries.nextElement()
if (entry.isDirectory()) {
val uiJIRAStructure: Map[String, Array[String]] = configuration.getMapArrays("flowMatch.UIProjectKeys")
var componentWithDiagrams = scala.collection.mutable.Map.empty[String, Array[Option[Elem]]]
var projectsWithComponentsAndDiagrams = scala.collection.mutable.Map.empty[String, scala.collection.mutable.Map[String,Array[Option[Elem]]]]
for ((project, components) <- uiJIRAStructure){
components.foreach(component =>
componentWithDiagrams += (component -> Files.getListOfDiagramFilesFromDirectory(project.concat("/").concat(component)))
)
projectsWithComponentsAndDiagrams += (project -> componentWithDiagrams)
}
@throws(classOf[ReadDBFeaturesException])
def getRequirementFeaturesFromDBByProject(project: String): Option[DataFrame] ={
var result: Option[DataFrame] = None
try{
val storedRFsDF = spark
.sqlContext
.read
.format("com.microsoft.azure.cosmosdb.spark")
.cosmosDB(featuresStorageMap)
.toDF()
@throws(classOf[JIRAException])
def getJIRARESTClient(): Option[JiraRestClient] = {
try {
val asyncClientFactory: AsynchronousJiraRestClientFactory = new AsynchronousJiraRestClientFactory()
result = Some(asyncClientFactory.createWithBasicHttpAuthentication(
new URI(baseUrl),
jiraUser,
jiraPwd
))
}catch{
val textFile = sc.textFile("hdfs://...")
val df = textFile.toDF("line")
val errors = df.filter(col("line").like("%ERROR%"))
errors.count()
errors.filter(col("line").like("%MySQL%")).count()
val df = sqlContext.createDataFrame(data).toDF("label", "features")
val lr = new LogisticRegression().setMaxIter(10)
val model = lr.fit(df)
val weights = model.weights
model.transform(df).show()
object Maps {
val colors = Map("red" -> 0xFF0000,
"turquoise" -> 0x00FFFF,
"black" -> 0x000000,
"orange" -> 0xFF8040,
"brown" -> 0x804000)
def main(args: Array[String]) {
for (name <- args) println(
colors.get(name) match {
case Some(code) =>