Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesus de Diego jesusjavierdediego

View GitHub Profile
View mock_test.go
package grpc
import (
gomock "github.com/golang/mock/gomock"
"golang.org/x/net/context"
"time"
"testing"
. "github.com/smartystreets/goconvey/convey"
utils "me/project/utils"
mock "me/project/grpc/grpcmock"
View mock.go
package grpcmock
import (
"google.golang.org/grpc"
gomock "github.com/golang/mock/gomock"
context "golang.org/x/net/context"
pb "me/project/protobuf"
)
type MockDigitalIdentityServiceClient struct {
View buf.yaml
version: v1beta1
lint:
use:
- DEFAULT
- FILE_LOWER_SNAKE_CASE
- COMMENTS
except:
- ENUM_NO_ALLOW_ALIAS
- IMPORT_NO_PUBLIC
- PACKAGE_AFFINITY
View idr.proto
syntax = "proto3";
package idrproto;
option go_package = "protobuf";
option optimize_for = SPEED;
message IDR {
ID user_id = 1;
View KafkaBatchProducer.java
public KafkaProducer<String, String> getBatchProducer() {
Properties properties = new Properties();
properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
//safe producer
properties.setProperty(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, "true");
properties.setProperty(ProducerConfig.ACKS_CONFIG, "all");
properties.setProperty(ProducerConfig.RETRIES_CONFIG, String.valueOf(Integer.MAX_VALUE));
View ValidateSignatures.scala
def validateAdESSignatures(businessId: String, filePath: String, packInfoOpt: Option[(String, Pack)]): (DocumentValidationResponse, Int) = {
import eu.europa.esig.dss.validation._
import eu.europa.esig.dss.validation.reports.Reports
val file: File = new File(filePath)
val document: DSSDocument = new FileDocument(file)
val pdfValidator: PDFDocumentValidator = new PDFDocumentValidator(document)
val errors: ArrayBuffer[String] = ArrayBuffer.empty[String]
if (pdfValidator.isSupported(document)) {
val certificateVerifier: CommonCertificateVerifier = new CommonCertificateVerifier()
View esign.proto
message DSR {
string correlationid = 1;
int64 requestTime = 2;
string authtoken = 3;
SignatureRequest SignatureRequest = 4;
DocumentReference document = 5;
OperationalContext context = 6;
}
// *
View SignatureAgent.scala
import java.io.File
import java.time.Instant
import java.sql.Timestamp
import java.util._
import java.security.KeyStore.PasswordProtection
import java.security.spec.DSAParameterSpec
import java.math.BigInteger
import org.slf4j.LoggerFactory
import eu.europa.esig.dss.enumerations._
import eu.europa.esig.dss.validation.CommonCertificateVerifier
View mergePurgeAndMakeListWithoutDup.scala
def mergePurgeAndMakeListWithoutDuplictes(listOfFoundDuplicates: DataFrame, personList: Dataset[Person]): DataFrame ={
import spark.implicits._
import scala.collection.mutable.ArrayBuffer
implicit val anyEncoder = org.apache.spark.sql.Encoders.kryo[Any]
var unifiedListOfPersons = ArrayBuffer.empty[Person]
val multipleDuplicates = listOfFoundDuplicates.filter($"num" > 1)
val noDuplicates = listOfFoundDuplicates.filter($"num" === 1)
multipleDuplicates.map(row => {
try{
unifiedListOfPersons += mergeDuplicatesForAGivenPerson(row.getAs[String]("id"), row.getAs[Set[String]]("duplicates"), personList)
View ModelComposer.scala
class ModelComposer extends Logging{
val operationType = "create"
@throws(classOf[ModelComposerException])
def getAllDFs(persons: DataFrame, sourceData: DataFrame): Map[String, DataFrame] = {
import spark.implicits._
import com.datastax.driver.core.utils.UUIDs
implicit val anyEncoder = org.apache.spark.sql.Encoders.kryo[Any]
var result: scala.collection.mutable.Map[String, DataFrame] = scala.collection.mutable.Map.empty[String, DataFrame]