Skip to content

Instantly share code, notes, and snippets.

Alexandre Aquiles alexandreaquiles

Block or report user

Report or block alexandreaquiles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alexandreaquiles
alexandreaquiles / CalculadoraDePrecos.java
Created Jul 4, 2018
Solução sugerida para exercício de Refatoração do PM-87.
View CalculadoraDePrecos.java
public class CalculadoraDePrecos {
public static BigDecimal calcula(Sessao sessao, Integer quantidade) {
return sessao.calcula(quantidade);
}
}
View FileUtils.java
package br.com.paradizo.tema;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
View FileUtils.java
public class FileUtils {
public static String getResourceContents(String resource) throws URISyntaxException, IOException {
Path resourcePath = getResourceAsPath(resource);
return getPathContents(resourcePath);
}
private static Path getResourceAsPath(String resource) throws URISyntaxException, IOException {
URI uri = FileUtils.class.getResource(resource).toURI();
View JacksonConfig.java
@Configuration
public class JacksonConfig {
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.GETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.SETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.CREATOR, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
@alexandreaquiles
alexandreaquiles / .bashrc
Created Mar 21, 2018
show current SDK Java version on the command prompt
View .bashrc
#show java version on prompt
current_sdk_java_version() {
export PS1="\e[0;32m$(sdk current java version | grep version | sed -e 's/.*version \(.*\)/\1/')\e[m$ "
}
PROMPT_COMMAND="current_sdk_java_version"
@alexandreaquiles
alexandreaquiles / EscapeXmlELResolverListener.java
Last active Dec 15, 2017
EscapeXmlELResolverListener for Spring Boot based on pukkaone.github.io/2011/01/03/jsp-cross-site-scripting-elresolver.html
View EscapeXmlELResolverListener.java
package br.com.caelum.fj91.seguranca;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.jsp.JspContext;
@alexandreaquiles
alexandreaquiles / show-module-resolution.txt
Last active Nov 30, 2017
Result of 'java --show-module-resolution' the unnamed module for Oracle JDK 9 (build 9.0.1+11)
View show-module-resolution.txt
root jdk.management.jfr jrt:/jdk.management.jfr
root jdk.jdi jrt:/jdk.jdi
root javafx.web jrt:/javafx.web
root jdk.xml.dom jrt:/jdk.xml.dom
root jdk.jfr jrt:/jdk.jfr
root jdk.packager.services jrt:/jdk.packager.services
root jdk.httpserver jrt:/jdk.httpserver
root javafx.base jrt:/javafx.base
root jdk.net jrt:/jdk.net
root javafx.controls jrt:/javafx.controls
@alexandreaquiles
alexandreaquiles / 2017-11-22.log
Created Nov 22, 2017
Warning when _ used as an identifier in Java 8. Compilation error in Java 9 (though, bytecode from Java 8 is executed).
View 2017-11-22.log
alexandre ~/keyword $ /usr/lib/jvm/java-8-oracle/bin/javac Keyword.java
Keyword.java:3: warning: '_' used as an identifier
int _ = 1;
^
(use of '_' as an identifier might not be supported in releases after Java SE 8)
Keyword.java:4: warning: '_' used as an identifier
System.out.println(_);
^
(use of '_' as an identifier might not be supported in releases after Java SE 8)
2 warnings
@alexandreaquiles
alexandreaquiles / MedicaoDeTempoFilter.java
Created Nov 17, 2017
Filter para medição de tempo
View MedicaoDeTempoFilter.java
package br.com.caelum.tarefas.filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
You can’t perform that action at this time.