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{
import akka.actor.{Actor, ActorSystem, Props}
import scala.io.Source
import scala.xml._
class WeatherActor extends Actor {
override def receive: Receive = {
case msg => println (msg)
}
}
import 'rxjs/add/operator/toPromise';
search(term:string) {
let promise = new Promise((resolve, reject) => {
let apiURL = `${this.apiRoot}?term=${term}&media=music&limit=20`;
this.http.get(apiURL)
.toPromise()
.then(
res => {
this.results = res.json().results;
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()