Skip to content

Instantly share code, notes, and snippets.

package iais.spark_dataset;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
@ehabqadah
ehabqadah / App.java
Last active May 10, 2017 11:26
Update a column of DataFrame in Spark, replacing the entire column with new values after applying certain function on old values e.g., MD5
package iais.spark_dataset;
import static org.apache.spark.sql.functions.*;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
@ehabqadah
ehabqadah / gist:467fde76a0b3d556dc8046be3a0643ca
Created July 14, 2017 04:19 — forked from reiz/gist:d67512deee814705134e
Vagrantfile for a Java dev. environment with Oracle Java 8 and Eclipse.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
/**
* <p> Root entity for object persistence via JPA.</p>
*
* @author Ehab Qadah
*/
@MappedSuperclass
public abstract class BaseEntity {
@Id
@GeneratedValue(generator = "custom-generator",
......
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 50
periodSeconds: 10
timeoutSeconds: 2
readinessProbe:
httpGet:
management.health.probes.enabled=true
management.endpoint.health.show-details=always
management.endpoint.health.group.readiness.include=*
management.endpoint.health.group.readiness.show-details=always
management.endpoint.health.group.liveness.include=ping
management.endpoint.health.group.liveness.show-details=always
/**
* Incoming DTO to create a new record of {@link com.qadah.demo.data.model.Order}
*
* @author Ehab Qadah
*/
public class OrderIncomingDto {
@JsonProperty(required = true)
@NotEmpty
@NotBlank
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.jdbc.time_zone=UTC
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/${MYSQL_DB:local_db}?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
spring.datasource.username=${MYSQL_USER:local_user}
spring.datasource.password=${MYSQL_PASSWORD:P@ssowrd1}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.show_sql=${SHOW_SQL:false}
spring.jpa.properties.hibernate.jdbc.batch_size=${JDBC_BACTH_SIZE:10}
/**
* * Handle all exceptions and java bean validation errors
* for all endpoints income data that use the @Valid annotation
*
* @author Ehab Qadah
*/
@ControllerAdvice
public class GeneralExceptionHandler extends ResponseEntityExceptionHandler {
public static final String ACCESS_DENIED = "Access denied!";