Skip to content

Instantly share code, notes, and snippets.

View rponte's full-sized avatar
🏠
Working from home

Rafael Ponte rponte

🏠
Working from home
View GitHub Profile
@rponte
rponte / build.sh
Created October 28, 2013 16:04 — forked from sergiolopes/build.sh
java -jar war/WEB-INF/lib/htmlcompressor-*.jar \
--type html --recursive --mask '*.jsp;*.html;*.tag;*.htm' \
--compress-css --compress-js --js-compressor closure \
--remove-intertag-spaces --remove-quotes \
--preserve-server-script -p regex.txt \
-o war/ war/ 2> /dev/null
@rponte
rponte / .htaccess
Created October 31, 2013 16:35 — forked from bhollis/.htaccess
AddEncoding gzip .gz
RewriteEngine on
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Konqueror
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)\.css$ $1.css.gz [QSA,L]
RewriteRule ^(.*)\.js$ $1.js.gz [QSA,L]
RewriteRule ^(.*)\.html$ $1.html.gz [QSA,L]
@rponte
rponte / nginx.conf
Created November 12, 2013 11:58 — forked from plentz/nginx.conf
#don't send the nginx version number in error pages and Server header
server_tokens off;
# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
# to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
module.exports = function(grunt) {
var config = {};
// Set all the tasks you want to load.
var tasks = [
, "grunt-contrib-concat"
, "grunt-contrib-uglify"
, "grunt-contrib-jshint"
, "grunt-contrib-watch"
];
public class Validate {
public static boolean not(boolean expression){
return !expression;
}
public static boolean in(String value, String[] options){
return StringUtil.in(value, options);
}
public class MyTest {
@Rule
public MethodRule screenshot = new ScreenshotOnFailureRule();
@Test
public void myTest() { ... }
...
}
package icob.web.interceptor;
import java.util.Iterator;
import java.util.Locale;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Specializes;
import javax.inject.Inject;
import javax.validation.ConstraintViolation;
import javax.validation.MessageInterpolator;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface PreventExternalAccess {
}
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
public class DatasImportantesNaoTestavel {
public LocalDate diaDoProgramadorDesseAno(){
//como fazer para testar uma data do passado, por exemplo, de 2012?
return LocalDate.now().with(TemporalAdjusters.firstDayOfYear()).plusDays(255);
}
}
package fx.time;
import java.sql.Date;
import java.time.LocalDate;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter(autoApply = true)
public class PersistentLocalDate implements AttributeConverter<LocalDate, Date> {