Skip to content

Instantly share code, notes, and snippets.

View brunoborges's full-sized avatar
🏠
Working from home, as always

Bruno Borges brunoborges

🏠
Working from home, as always
View GitHub Profile
@brunoborges
brunoborges / gist:1052097
Created June 28, 2011 20:23 — forked from matthewmccullough/gist:47267
Show Git dirty status in your Unix bash prompt (symbols not compatible with CygWin)
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@brunoborges
brunoborges / DSLWicket.scala
Created July 27, 2011 15:22
Scala DSL for Wicket
package code.webapp
import scala.collection.JavaConversions.seqAsJavaList
import org.apache.wicket.behavior.AttributeAppender
import org.apache.wicket.datetime.markup.html.form.DateTextField
import org.apache.wicket.extensions.validation.validator.RfcCompliantEmailAddressValidator
import org.apache.wicket.markup.html.basic.{ MultiLineLabel, Label }
import org.apache.wicket.markup.html.form.{ TextField, TextArea, SubmitLink, RadioGroup, Radio, PasswordTextField, FormComponent, Form, DropDownChoice, CheckGroup, Button }
import org.apache.wicket.markup.html.link.{ Link, BookmarkablePageLink }
import org.apache.wicket.markup.html.link.ExternalLink
@brunoborges
brunoborges / MeuEvento.scala
Created July 27, 2011 17:27
Usage of DSLWicket
package code.pages
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation
import org.apache.wicket.markup.html.form.Button
import org.apache.wicket.markup.html.form.Form
import org.apache.wicket.markup.html.WebMarkupContainer
import org.apache.wicket.spring.injection.annot.SpringBean
import org.springframework.stereotype.Service
import code.model.Evento
import code.services.EventosService
@brunoborges
brunoborges / gist:1225864
Created September 19, 2011 02:07
Wicket and Scala, the power of DSLs
val opcoesCha = servico.find()
// #1 - regular Scala+Wicket code
val chaCozinha = new WebMarkupContainer("chaCozinha")
val chaBar = new WebMarkupContainer("chaBar")
val chaBarnela = new WebMarkupContainer("chaBarnela")
add(chaCozinha, chaBar, chaBarnela)
chaCozinha.setDefaultModel(new CompoundPropertyModel(opcoesCha))
chaBar.setDefaultModel(new CompoundPropertyModel(opcoesCha))
List lst = null;
lst = new ArrayList(10);
lst = myService.findAll();
// Programmers... PLEASE... STOP ... DOING... THIS!!
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function showDiff() {
var s1 = $("#first").val();
var s2 = $("#second").val();
var d1 = toDate(s1);
var d2 = toDate(s2);
@brunoborges
brunoborges / Routes.scala
Created June 9, 2012 05:05
Routing pages with Gamboa (Scala and Wicket)
trait Routes {
self: DSLRouter ⇒
def initRoutes {
"/login" -> classOf[Login]
"/index" -> classOf[Index]
}
}
@brunoborges
brunoborges / gist:2908606
Created June 11, 2012 05:12
No #TDC2012 vc talvez aprenda a usar Scala, Apache Camel e o Twitter :-)
class MyRouteBuilder extends RouteBuilder {
val tweetMsg = (e: Exchange) ⇒ {
val tweet = new StatusUpdate("@%s ei, se minha palestra for aceita, voce vai aprender como usar Scala, Apache Camel e Twitter!".format(status.getFromUser()))
tweet.setInReplyToStatusId(e.getIn.getBody.asInstanceOf[Tweet].getId())
e.getIn().setBody(tweet)
}
"twitter://search?delay=10&type=polling&keywords=%23TDC2012%20scala%20camel%20twitter" ==> {
when(_.in.asInstanceOf[Tweet].getFromUser() != "brunoborges") {
@brunoborges
brunoborges / module.xml
Created June 20, 2012 16:53
JBoss module for Spring
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.springframework.spring">
<resources>
<resource-root path="cglib-nodep-2.2.2.jar"/>
<resource-root path="aopalliance-1.0.0.jar"/>
<resource-root path="spring-aop-3.1.1.RELEASE.jar"/>
<resource-root path="spring-asm-3.1.1.RELEASE.jar"/>
<resource-root path="spring-beans-3.1.1.RELEASE.jar"/>
<resource-root path="spring-context-3.1.1.RELEASE.jar"/>
<resource-root path="spring-context-support-3.1.1.RELEASE.jar"/>
@brunoborges
brunoborges / pom.xml
Created June 21, 2012 03:09
JBoss custom module for Shared Library using Maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<Dependencies>com.mycompany.mymodule</Dependencies>