Skip to content

Instantly share code, notes, and snippets.

View ilopmar's full-sized avatar

Iván López ilopmar

  • VMware
  • Madrid, Spain (Remote)
  • X @ilopmar
View GitHub Profile
@yvesf
yvesf / README.md
Created January 13, 2016 16:56
Grails 3 Run-Command

Grails 3 no longer contains the functionality to execute Scripts within an running application context. Grails 2.x contained the 'run-script' command and also allowed to run arbitrary scripts implemented as Gant tasks under $dir/scripts directory of any project.

As a substitute grails 3 offers ApplicationContext Commands. The downside is that they cannot be implemented in the actual project because they have to be in the gradle buildscript classpath as well. This is also not desirable because one don't want to pollute this classpath with application dependencies.

This project provides a workaround for that. It is on one side a grails project and registers exactly one command that

@CaptainOfFlyingDutchman
CaptainOfFlyingDutchman / external_configuration_in_grails_3.md
Last active September 23, 2019 09:19
Enable external configuration in Grails 3

External configuration in Grails 3


Working on Grails 3 I realized that I no longer can specify external configuration using the standard grails.config.locations property in Config.groovy file.

Reason is obvious! There is no Config.groovy now in Grails 3. Instead we now use application.yml to configure the properties. However, you can't specify the external configuration using this file too!

What the hack?

Now Grails 3 uses Spring's property source concept. To enable external config file to work we need to do something extra now.

@musketyr
musketyr / AbstractIntegrationSpec.groovy
Created February 18, 2015 13:58
how to be sure the test runs only against data from fixtures
abstract class AbstractIntegrationSpec extends IntegrationSpec {
@Shared
def fixtureLoader, fixtures, initCatalogueService, sessionFactory
def loadFixtures(){
String scriptLocation = "${System.getProperty('java.io.tmpdir')}mc/testdata.sql"
def sql = new Sql(sessionFactory.currentSession.connection())
@melix
melix / README.adoc
Last active July 7, 2021 07:37
An automated solver for 2048

Automated solver for 2048

This is a script which runs a "bot" that tries to solve the incredibly addictive 2048 game. It makes use of Groovy and browser automation with Geb.

How to

  • First step, if you don’t have it, you need to install Groovy.

  • Second step is to install the Google Chrome WebDriver (just unzip the appropriate file to a local directory)

  • Next, edit the script to set the path to the Chrome Driver

  • then execute the script: groovy solver2048.groovy

@ColinHarrington
ColinHarrington / .gitconfig
Last active August 29, 2015 13:56
.gitconfig
[branch]
autosetuprebase = always
[mergetool "p4merge"]
cmd = /home/<username>/dir/to/p4v/bin/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
keepTemporaries = false
trustExitCode = false
keepBackup = false
[merge]
@GrabResolver(name='grails-core', root='http://repo.grails.org/grails/core')
@Grab(group='org.grails', module='grails-datastore-gorm-mongo', version='1.0.0.BUILD-SNAPSHOT')
@Grab(group='org.slf4j', module='slf4j-simple', version='1.6.1')
import grails.persistence.*
import org.grails.datastore.gorm.mongo.config.*
MongoDatastoreConfigurer.configure("myDatabase", Book)
Book.withSession {
@mariogarcia
mariogarcia / GradleGroovyConsole
Created February 4, 2014 08:39
Launching a Groovy Console with your Gradle classpath
task(console, dependsOn: 'classes', type: JavaExec) {
main = 'groovy.ui.Console'
classpath = sourceSets.main.runtimeClasspath
}
@robpatrick
robpatrick / CreatedAndLastUpdated.groovy
Created November 3, 2013 12:47
The Grails ORM technology - GORM, has the ability to auto-timestamp GORM objects with the date and time they were created and last updated, details can be found here: http://grails.org/doc/latest/guide/GORM.html#eventsAutoTimestamping Our developers didn't like to have to litter our GORM code with these attributes so I created an AST transformat…
package com.alkalinezoo.transform
import java.lang.annotation.Target
import java.lang.annotation.ElementType
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import org.codehaus.groovy.transform.GroovyASTTransformationClass
/**
* Simple annotation that when used on a class adds two new fields of type {@code java.util.Date}
@danveloper
danveloper / Application.groovy
Created October 10, 2013 18:00
An example of using the Spring Integration Groovy DSL with a JMS channel adapter to an embedded ActiveMQ JMS broker
package com.danveloper.springboot
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.integration.dsl.groovy.IntegrationContext
import org.springframework.integration.dsl.groovy.builder.AbstractIntegrationBuilderModuleSupport
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.support import ui
from selenium.common.exceptions import NoSuchElementException, TimeoutException
def create_browser():
profile = webdriver.FirefoxProfile()
profile.set_preference('permissions.default.image', 2)
profile.update_preferences()
return webdriver.Firefox(profile)