View Calculadora.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
View Capitalize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class Capitalize { | |
public static String capitalize (String x) { | |
return x.substring(0,1).toUpperCase() + x.substring(1).toLowerCase(); | |
} | |
public static void main(String[] args) { | |
String text = "gabinete do deputado fulando de tal e de dona maria"; |
View LinkToHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@ApplicationScoped | |
public class LinkToHandler implements StereotypeHandler { | |
private Map<String, Map<String, Linker>> linkTo = Maps.newHashMap(); | |
private final ServletContext context; | |
private final Router router; | |
public LinkToHandler(ServletContext context, Router router) { | |
this.context = context; |
View invariants.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def billing-violations [negative-entries small-minimum-payment prepaid-mutual]) | |
(def loss-violations [credit-loss pre-loss]) | |
(def general-violations [minimum-payment-mutual]) | |
(defn all-violations [balances] | |
(concat billing-violations loss-violations general-violations)) | |
(s/defn fixing-invariants :- [Entry] [initial-balances :- Balances, new-entries :- [Entry]] |
View mapper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mapper | |
def self.map!(options = {}) | |
drop_index! if options[:delete] | |
Tire.index :index_name do | |
create :analysis => { | |
:filter => { | |
:pt_br_filter => { | |
:type => :stemmer, | |
:language => :minimal_portuguese |
View LazyJSONSerialization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class LazyJSONSerialization extends XStreamJSONSerialization { | |
private SerializerHolder holder; | |
public LazyJSONSerialization(SerializerHolder holder, HttpServletResponse response, TypeNameExtractor extractor, ProxyInitializer initializer, XStreamBuilder builder) { | |
super(response, extractor, initializer, builder); | |
this.holder = holder; | |
} | |
@Override | |
protected SerializerBuilder getSerializer() { | |
try { |
View PackageResourceHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component // do vraptor | |
@ApplicationScoped | |
@org.springframework.stereotype.Component("stereotypeHandler") // só se for spring | |
public class PackageResourceHandler implements StereotypeHandler { | |
private final Map<String, Class> controllers; | |
private final Map<String, Class> gerenciador; | |
public PackageResourceHandler(ServletContext context) { | |
context.setAttribute("controllers", controllers); | |
context.setAttribute("gerenciador", gerenciador); |
View PackageRoutesParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@ApplicationScoped | |
public class PackageRoutesParser extends PathAnnotationRoutesParser { | |
//delegate constructor | |
public PackageRoutesParser(Router router) { | |
super(router); | |
} | |
@Override |
View Redirect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Result result = //... | |
ResourceMethod method = //... | |
Object[] args = //... | |
Object redirecting = result.redirectTo(method.getResource().getType()); | |
new Mirror().on(redirect).invoke().method(method.getMethod()).withArgs(args); |
View SessionCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@RequestScoped | |
public class SessionCreator implements ComponentFactory<Session> { | |
private final SessionFactory factory; | |
private final Proxifier proxifier; | |
private Session session; | |
public SessionCreator(SessionFactory factory, Proxifier proxifier) { | |
this.factory = factory; | |
this.proxifier = proxifier; |
NewerOlder