Skip to content

Instantly share code, notes, and snippets.

View fmamud's full-sized avatar
💻

Felipe Mamud fmamud

💻
View GitHub Profile
@fmamud
fmamud / Ls.groovy
Last active April 22, 2016 15:19
Add unix ls command to groovysh
// open groovysh
// execute :rc ls
import org.codehaus.groovy.tools.shell.CommandSupport
import org.codehaus.groovy.tools.shell.Groovysh
class Ls extends CommandSupport {
protected Ls(final Groovysh shell) {
super(shell, ':ls', ':dir')
}
@fmamud
fmamud / build.gradle
Created May 15, 2016 01:08
TDC 2016 Floripa - Palestra Gradle: o melhor amigo no build do seu software
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'org.apache.commons:commons-lang3:3.4'
}
@fmamud
fmamud / tdc.erl
Created July 6, 2016 14:34
TDC 2016 São Paulo - Palestra: Erlang sem enrolação
-module (tdc).
-export ([printer/0, mysum/1, loop/0]).
printer() ->
io:format("~p~n", ["Bem vindos ao TDC 2016"]).
mysum([]) ->
0;
mysum([H|T]) ->
@fmamud
fmamud / ast.groovy
Last active July 11, 2016 17:22
TDC São Paulo - Palestra: Groovy como você nunca viu
package tdc.groovy.awesome
import groovy.transform.Immutable
import groovy.transform.ToString
// @TypeChecked
// @CompileStatic
@ToString
@Immutable
@fmamud
fmamud / MyExtension.groovy
Created August 4, 2016 05:39
Groovy compiler customization with type checking and static compilation
beforeVisitMethod { methodNode ->
println "calling ${methodNode.name}(${methodNode.parameters.join(',')})"
}
afterMethodCall { call ->
if (getTargetMethod(call).name=='plus') {
addStaticTypeError('plus() not allowed',call)
handled = true
}
@fmamud
fmamud / MySpec.groovy
Created October 13, 2016 18:53
Spock Specification
import spock.lang.*
class MySpec extends Specification {
// fields
// fixture methods
// feature methods
// helper methods
}
@fmamud
fmamud / MySpec.groovy
Last active October 14, 2016 03:50
First method in Spock Specification
import spock.lang.*
class MySpec extends Specification {
def "should return 4 after list sum"() {
given:
List<Integer> list = new ArrayList<>()
when:
list.add(2)
then:
@fmamud
fmamud / MySpec.groovy
Created October 13, 2016 21:24
Spock assert error
MySpec > should return 4 after list sum FAILED
Condition not satisfied:
4 == list.sum()
| | |
| [2] 2
false
at MySpec.should return 4 after list sum(MySpec.groovy:15)
1 test completed, 1 failed
@fmamud
fmamud / MySpec.groovy
Created October 14, 2016 03:05
Expect and Setup sections in Spock Specification
import spock.lang.*
class MySpec extends Specification {
def "should return 4 after list sum"() {
setup:
def list = [2, 2]
expect:
4 == list.sum()
@fmamud
fmamud / MySpec.groovy
Created October 14, 2016 03:26
Data Table in Spock Specification
import spock.lang.*
class MySpec extends Specification {
def "maximum of two numbers"(int a, int b, int c) {
expect:
Math.max(a, b) == c
where:
a | b | c