Skip to content

Instantly share code, notes, and snippets.

View arthurportas's full-sized avatar

Arthur Portas arthurportas

  • Jumia
  • Porto-Portugal
View GitHub Profile
@arthurportas
arthurportas / JasperReportsApplication.java
Created January 11, 2017 23:42
Sample blank pdf generation using JasperReports Java API
package com.arthurportas.jasperreports;
import net.sf.jasperreports.engine.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.HashMap;
@arthurportas
arthurportas / Configuration.java
Last active July 27, 2022 00:36
Sample configuration Spring-Cloud-AWS, File services and Controller
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3Client;
import org.springframework.cloud.aws.context.config.annotation.EnableContextCredentials;
import org.springframework.cloud.aws.context.config.annotation.EnableContextResourceLoader;
import org.springframework.cloud.aws.context.support.io.ResourceLoaderBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@arthurportas
arthurportas / ApplicationConfig.java
Last active November 17, 2021 11:07
Sample spring mongodb project setup with mongodb custom converters
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
#org.slf4j.simpleLogger.defaultLogLevel=info
# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").
import org.apache.maven.cli.MavenCli;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Paths;
@arthurportas
arthurportas / ScheduledTasks.java
Created January 28, 2017 19:47
ScheduledTasks.java
package com.arthurportas.mongodb.example.tasks;
import com.arthurportas.mongodb.example.repository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.ParseException;
@arthurportas
arthurportas / ApplicationConfig.java
Created March 13, 2016 13:55
Sample spring-data jpa query with querydsl
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>new-employee.html</welcome-file>
</welcome-file-list>
@arthurportas
arthurportas / EmployeeController.java
Created May 27, 2017 16:19
EmployeeController.java
package com.arthurportas.presentation.servlets;
import com.arthurportas.entities.Employee;
import com.arthurportas.services.EmployeeService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@arthurportas
arthurportas / new-employee.html
Created May 27, 2017 16:19
new-employee.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>::StaffGest:: - new-employee</title>
<meta name="description" content="StaffGest:: - search-employee">
<meta name="author" content="Arthur Portas">
</head>
<body>