Skip to content

Instantly share code, notes, and snippets.

Avatar

Lucas Cavalcanti lucascs

View GitHub Profile
@lucascs
lucascs / boleto.clj
Created Feb 26, 2014
Caelum Stella em Clojure
View boleto.clj
(ns accounts.adapters.boleto
(:import (br.com.caelum.stella.boleto
Datas Sacado Emissor Boleto
bancos.Santander transformer.GeradorDeBoleto)))
(defn generate []
(let [datas (-> (Datas/novasDatas)
(.comDocumento 15 2 2014)
(.comProcessamento 15 2 2014)
(.comVencimento 17 2 2014))
View CidLogicResult.java
@Specializes
@RequestScoped
public class CidLogicResult extends DefaultLogicResult {
private MutableRequest request;
public CidLogicResult(...., MutableRequest request) {
super(....);
this.request = request;
}
@Override
View 1_basics.rb
p "Hello World"
#!/usr/bin/ruby
irb
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;
}