Skip to content

Instantly share code, notes, and snippets.

View jmigueprieto's full-sized avatar

Miguel Prieto jmigueprieto

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jmigueprieto on github.
  • I am jmigueprieto (https://keybase.io/jmigueprieto) on keybase.
  • I have a public key ASB1r4e48r9iUPH_q0uzMWq-GhIrKyctwR0mWWhYjqB3uQo

To claim this, I am signing this object:

@jmigueprieto
jmigueprieto / PassEncode.groovy
Created February 6, 2020 21:05
Groovy Script that uses BCryptPasswordEncoder to encode a password
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.crypto.password.PasswordEncoder
@Grab(group = 'org.springframework.boot', module = 'spring-boot-starter-security', version = '2.2.4.RELEASE')
String plainPassword = '12345'
PasswordEncoder encoder = new BCryptPasswordEncoder()
println encoder.encode(plainPassword)
@jmigueprieto
jmigueprieto / selenium_webdriver_example.groovy
Last active January 21, 2020 03:44
Example of how to use Selenium Webdriver (Chrome driver). It googles "How to use selenium webdriver".
@Grab(group = 'org.seleniumhq.selenium', module = 'selenium-java', version = '3.141.59')
@Grab(group = 'org.seleniumhq.selenium', module = 'selenium-chrome-driver', version = '3.141.59')
import org.openqa.selenium.By
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait
// This property has to be set to chrome driver executable
// SEE: https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver
System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver")
@jmigueprieto
jmigueprieto / rabbitmq_dead_letter.groovy
Created January 11, 2020 15:41
Groovy Script that shows how to configure dead lettering for a queue using Spring Boot AMQP Starter
@Grab(group = 'org.springframework.boot', module = 'spring-boot-starter-amqp', version = '2.2.2.RELEASE')
import org.springframework.amqp.core.*
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory
import org.springframework.amqp.rabbit.core.RabbitAdmin
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
// Messages sent to LAZY_QUEUE will dead letter to WORK_QUEUE if they expire
final String EXCHANGE = 'my_exchange'
final String WORK_QUEUE = 'work_queue'
final String LAZY_QUEUE = 'lazy_queue' // no consumers for this queue
@jmigueprieto
jmigueprieto / rabbitmq_listener.groovy
Created January 10, 2020 21:24
Groovy Script that creates a listener/consumer for a RabbitMQ queue using spring-boot-starter-amqp
@Grab(group = 'org.springframework.boot', module = 'spring-boot-starter-amqp', version = '2.2.2.RELEASE')
import org.springframework.amqp.core.*
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory
import org.springframework.amqp.rabbit.core.RabbitAdmin
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
import java.nio.charset.Charset
final String EXCHANGE = 'tickets'
final String QUEUE = 'events'
@jmigueprieto
jmigueprieto / amqp_send_json_message.groovy
Created January 10, 2020 21:18
Groovy Script to send a JSON message to a Rabbitmq broker
@Grab(group = 'com.fasterxml.jackson.core', module = 'jackson-databind', version = '2.10.1')
@Grab(group = 'org.springframework.boot', module = 'spring-boot-starter-amqp', version = '2.2.2.RELEASE')
import org.springframework.amqp.rabbit.core.RabbitTemplate
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter
def cf = new CachingConnectionFactory(new URI('amqp://guest:guest@localhost:5672'))
def template = new RabbitTemplate(cf)
template.messageConverter = new Jackson2JsonMessageConverter()