Skip to content

Instantly share code, notes, and snippets.

package boothello;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/")
public CustomResponse index() {
package boothello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>curso-spring</groupId>
<artifactId>hello-world-spring-boot</artifactId>
<version>1.0-SNAPSHOT</version>
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@AlfredoCasado
AlfredoCasado / gist:8601134
Created January 24, 2014 16:46
Publish a photo in a facebook fan page. Using groovy and RestFB API.
@Grapes(
@Grab(group='com.restfb', module='restfb', version='1.6.12')
)
import com.restfb.DefaultFacebookClient
import com.restfb.json.JsonObject
import com.restfb.types.FacebookType
import com.restfb.Parameter
import com.restfb.BinaryAttachment
import java.io.FileInputStream
@AlfredoCasado
AlfredoCasado / gist:8545531
Created January 21, 2014 18:34
Groovy script that fetch all feeds with comments and 2nd level comments from a facebook page, using the library RestFB.
@Grapes(
@Grab(group='com.restfb', module='restfb', version='1.6.12')
)
import com.restfb.DefaultFacebookClient
import com.restfb.Parameter
import com.restfb.types.*
def token = "FACEBOOK_AUTH_TOKEN"
def page_id = "PAGE_ID"
@AlfredoCasado
AlfredoCasado / AnaemicModel.java
Last active December 14, 2015 08:29
Repository example in groovy using groovy.sql
@Entity
@Table(name = "miniblog_comment")
@SuppressWarnings("serial")
public class MiniblogComment implements Serializable, EntityParent {
/**
* Attribute commentId.
*/
private String commentId;
if (tieneElUsuarioFondos){
pasarelaDePago.cobrar(elPrecioDeLaCompra);
pasarelaDePago.confirmar();
}
public class CompraTestSpies {
PasarelaDePago pasarelaDePagoSpy = mock(PasarelaDePago.class);
Producto unProductoStub = mock(Producto.class);
Compra compra = new Compra(pasarelaDePagoSpy);
@Test public void
si_el_cliente_tiene_fondos_para_realizar_la_compra_tengo_que_cobrarle_a_traves_de_la_pasarela_de_pago() {
when(unProductoStub.precio()).thenReturn(50);
when(pasarelaDePagoSpy.tieneElUsuarioFondosPorValorDe(50)).thenReturn(false);
boolean confirmar() {
int elPrecioDeLaCompra = precio();
boolean tieneElUsuarioFondos = pasarelaDePago.tieneElUsuarioFondosPorValorDe(elPrecioDeLaCompra);
if (tieneElUsuarioFondos){
pasarelaDePago.cobrar(elPrecioDeLaCompra);
}
return tieneElUsuarioFondos;
}