Skip to content

Instantly share code, notes, and snippets.

View OsaSoft's full-sized avatar

Oscar Hernández OsaSoft

View GitHub Profile
@OsaSoft
OsaSoft / RepositoryTest.groovy
Created January 12, 2018 13:22
Spock Spring workaround to using injected Spring beans in Where block
@SpringBootTest(classes = [ApplicationTest.class])
@ActiveProfiles("test")
class RepositoryTest {
@Autowired
IDeviceRepository deviceRepository
@Autowired
IGroupRepository groupRepository
@Autowired
IPlatformRepository platformRepository
@OsaSoft
OsaSoft / BootstrapTagLib.groovy
Last active January 9, 2018 07:28
Grails 3 using g:paginate with Twitter Bootstrap
import grails.util.TypeConvertingMap
import grails.web.mapping.UrlMapping
import org.grails.plugins.web.taglib.UrlMappingTagLib
import org.springframework.web.servlet.support.RequestContextUtils
class BootstrapTagLib extends UrlMappingTagLib {
Closure paginate = { Map attrsMap ->
TypeConvertingMap attrs = (TypeConvertingMap)attrsMap
def writer = out
if (attrs.total == null) {
@OsaSoft
OsaSoft / FacebookController.groovy
Created September 25, 2017 11:17
Grails 3 Spring Security Rest - Native Facebook mobile login
class FacebookController {
def authenticationEventPublisher
def userDetailsService
def tokenGenerator
def tokenStorageService
def accessTokenJsonRenderer
def facebookService
//...
@OsaSoft
OsaSoft / InjectReadyClass.java
Last active September 26, 2017 16:40
Spring Autowiring in instances that are not managed Spring beans
class InjectReadyClass {
@Autowired
public MyCoolService myCoolService; //public just for showing purposes
InjectReadyClass(ApplicationContext ctx) {
ctx.getAutowireCapableBeanFactory().autowireBeanProperties(
this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false
);
}

Keybase proof

I hereby claim:

  • I am osasoft on github.
  • I am oscarcz (https://keybase.io/oscarcz) on keybase.
  • I have a public key ASC7Wb9f-IBJVa-Gm88pLAl8OXREr3mtzAh2dlvk5Fr6dQo

To claim this, I am signing this object: