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
lucascs /
Created Aug 28, 2012
SessionCreator for Spring environments
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;
lucascs /
Created Aug 15, 2012
Forcing commit on redirects
public class RedirectCommitInterceptor implements Interceptor {
private Session session;
private MutableResponse response;
public RedirectCommitInterceptor(Session session, MutableResponse response) {
this.session = session;
this.response = response;
public boolean accept(ResourceMethod method) {
public class MapConverter implements Converter { //from XStream
//unmarshal => empty
public boolean canConvert(Class type) { return Map.class.isAssignableFrom(type); }
public void marshal(Object value, HierarchicalStreamWriter writer, MarshalingContext context) {
Map<String, Object> map = (Map<String, Object>) value; //assuming this
lucascs / CalendarParser.scala
Created Jun 29, 2012
Parser de datas em Scala
View CalendarParser.scala
package me.cavalcanti.lucas
import org.joda.time.LocalDate
import org.joda.time.format.DateTimeFormatter
import org.joda.time.format.DateTimeFormat
import scala.util.parsing.combinator.JavaTokenParsers
import org.joda.time.Period
class CalendarParser extends JavaTokenParsers {
View .bashrc
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\w$(__git_ps1 "\[\033[0;31m\](%s)")\[\033[00m\]\$ '
alias branch='git br | grep "*" | sed "s/\* //"'
alias gc='git commit -v'
alias gs='git status'
alias gp='git push origin `branch`'
alias gl='git pull origin `branch`'
alias grl='git pull --rebase origin `branch`'
alias ga='git add'
alias gb='git branch'
lucascs /
Created Jun 1, 2012
Filter for removing blank id parameters
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
lucascs /
Created Apr 27, 2012
Calendar converter for date and time
public class DateAndTimeCalendarConverter extends LocaleBasedCalendarConverter {
private final Localization localization;
public DateAndTimeCalendarConverter(Localization localization) {
this.localization = localization;
public Calendar convert(String value, Class<? extends Calendar> type, ResourceBundle bundle) {
if (Strings.nullToEmpty(value).length() > "dd/mm/yyyy".length()) {
lucascs /
Created Oct 14, 2011
generic converter for Json -> object #VRaptor
public interface Jsonable { }
lucascs /
Created Jul 5, 2011
Anatomia de uma solução - VRaptor linkTo para jsp
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;
lucascs /
Created Jul 4, 2011
overriding json serialization from VRaptor to cope with dates
import com.thoughtworks.xstream.converters.basic.DateConverter;
public class CustomJSONSerialization extends XStreamJSONSerialization {
public CustomJSONSerialization(HttpServletResponse response,TypeNameExtractor extractor, ProxyInitializer initializer) {
super(response, extractor, initializer);
public XStream getXStream() {
You can’t perform that action at this time.