Skip to content

Instantly share code, notes, and snippets.

Lucas Cavalcanti lucascs

  • Nubank
Block or report user

Report or block lucascs

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
View server.rb
post '/junit-results' do
result = JSON.parse(request.body.read)
passes = result['stats']['passes']
failures = result['stats']['failures']
File.open(File.dirname(__FILE__) + '/../../target/artifacts/reports/javascript.xml', 'w') do |f|
xml = Builder::XmlMarkup.new
suite = xml.testsuite :errors => 0, :failures => failures, :tests => passes, :name => "javascript.tests" do
result['results'].each do |tc|
unless tc.nil?
tc['specs'].each do |s|
@lucascs
lucascs / HackedParametersProvider.java
Created Nov 10, 2010
ignore blank request parameters
View HackedParametersProvider.java
@Component
public class HackedParametersProvider extends OgnlParametersProvider {
public HackedParametersProvider(...., HttpServletRequest request, ...) {
super(....., new HackedRequest(request), ....);
}
}
@lucascs
lucascs / FreemarkerPathResolver.java
Created Nov 23, 2010
How to change JSP to Freemarker in VRaptor.
View FreemarkerPathResolver.java
@Component
public class FreemarkerPathResolver extends DefaultPathResolver {
//delegate constructor
@Override
protected String getPrefix() {
return "/WEB-INF/freemarker/";
}
View DisplayTag.java
@Target(ElementType.METHOD)
@Retention(RetentionType.RUNTIME)
public @interface DisplayTag {
String value();
}
@lucascs
lucascs / Basket.java
Created Dec 20, 2010
simple hypermedia example
View Basket.java
public class Basket implements HypermediaResource {
private int id;
private String name;
public void configureRelations(RelationBuilder builder) {
builder.relation("self").uses(ItemController.class).showItem(id);
builder.relation("basket").at("/Basket/add/"+id);
}
@lucascs
lucascs / Out.java
Created Dec 22, 2010
support for VRaptor2's @out annotation
View Out.java
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Out {
}
View TenantRoutesParser.java
@Component
@ApplicationScoped
public class TenantRoutesParser implements RoutesParser {
private final RoutesParser parser;
public TenantRoutesParser(RoutesParser parser) {
this.parser = parser;
}
@lucascs
lucascs / CustomProvider.java
Created Feb 1, 2011
overriding guice's module
View CustomProvider.java
package my.apps.package;
public class CustomProvider extends GuiceProvider {
static class CustomModule extends AbstractModule {
private final Module module;
CustomModule(Module module) {
this.module = module;
}
@lucascs
lucascs / Calculadora.java
Created Feb 21, 2011
Programação funcional em Java
View Calculadora.java
public class Calculadora {
private static final Prova _ = of(Prova.class);
public double mediaDeProvas(List<Prova> provas) {
return mediaPonderada(provas, function(_.getNota()), function(_.getPeso()));
}
public <T> double mediaPonderada(List<T> lista, Function<T, Double> valor, Function<T, Double> peso) {
double soma = 0.0;
double somaPesos = 0.0;
@lucascs
lucascs / ActiveRecord.scala
Created Apr 5, 2011
Scala Active Record with DI
View ActiveRecord.scala
@Component
class ActiveRecord[T](session:Session) {
implicit def obj2AR(obj:T) = new AR(session, obj)
}
class AR[T](session:Session, obj:T) {
def save = session.save(obj)
}
You can’t perform that action at this time.