Skip to content

Instantly share code, notes, and snippets.

View tyama's full-sized avatar
💤

Tsuyoshi Yamamoto tyama

💤
  • newcast inc.
  • Tajimi,Japan
  • 20:31 (UTC +09:00)
View GitHub Profile
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
//classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
//classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.2"
}
//add this to your spring security config.
grails.plugin.springsecurity.rejectIfNoRule = false
grails.plugin.springsecurity.fii.rejectPublicInvocations = false
grails.plugin.springsecurity.ipRestrictions = [
'/shutdown':['127.0.0.1']
]
package app;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.boot.SpringApplication;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.web.servlet.ModelAndView;
@tyama
tyama / script-gorm-hibernate4.groovy
Created April 8, 2015 08:42
Using GORM for Hibernate4 in a Groovy Script
@Grab("org.grails:grails-datastore-gorm-hibernate4:3.1.4.RELEASE")
@Grab("com.h2database:h2:1.3.173")
@Grab("org.grails:grails-spring:2.5.0")
@Grab('org.slf4j:slf4j-simple:1.7.12')
import grails.orm.bootstrap.*
import grails.persistence.*
import org.springframework.jdbc.datasource.DriverManagerDataSource
import org.h2.Driver
def init = new HibernateDatastoreSpringInitializer(Person)
@tyama
tyama / boot-gorm-hibernate4.groovy
Last active August 29, 2015 14:18 — forked from graemerocher/boot-gorm-hibernate4.groovy
Using GORM for Hibernate 4 in Spring Boot
@Grab("org.grails:gorm-hibernate4-spring-boot:1.1.0.RELEASE")
@Grab("com.h2database:h2:1.3.173")
import grails.persistence.*
import org.springframework.http.*
import static org.springframework.web.bind.annotation.RequestMethod.*
// curl -XPOST http://localhost:8080/person/add -F 'firstName=Tony'
// curl -XGET 'http://localhost:8080/person/greet?firstName=Tony'
@RestController
class GreetingController {
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'idea'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1+')
#ifdef DEBUG
# define LOG(...) NSLog(__VA_ARGS__)
# define LOG_CURRENT_METHOD NSLog(@"%@/%@", NSStringFromClass([self class]), NSStringFromSelector(_cmd))
# define LogPoint(p) LOG(@"%s:%@",#p,NSStringFromCGPoint(p))
# define LogRect(r) LOG(@"%s:%@",#r,NSStringFromCGRect(r))
# define LogSize(s) LOG(@"%s:%@",#s,NSStringFromCGSize(s))
#else
# define LOG(...) ;
# define LOG_CURRENT_METHOD ;
@tyama
tyama / script-gorm-mongodb.groovy
Last active August 29, 2015 13:57 — forked from graemerocher/script-gorm-mongodb.groovy
Using GORM for MongoDB in a Groovy Script
@Grab("org.grails:grails-datastore-gorm-mongodb:4.0.0.RELEASE")
@Grab("org.springframework:spring-expression:4.1.6.RELEASE")
@Grab('org.slf4j:slf4j-simple:1.7.12')
import grails.persistence.*
import grails.mongodb.geo.*
import grails.mongodb.bootstrap.*
import org.bson.types.ObjectId
import com.mongodb.BasicDBObject
def initializer = new MongoDbDataStoreSpringInitializer(City)
@tyama
tyama / boot-gorm-mongodb.groovy
Last active August 29, 2015 13:57 — forked from graemerocher/boot-gorm-mongodb.groovy
Using GORM for MongoDB in Spring Boot
@Grab('org.grails:gorm-mongodb-spring-boot:1.1.0.RELEASE')
import grails.persistence.*
import grails.mongodb.geo.*
import org.bson.types.ObjectId
import com.mongodb.BasicDBObject
import com.mongodb.Mongo
import org.springframework.http.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.mongodb.core.mapping.MongoMappingContext
import static org.springframework.web.bind.annotation.RequestMethod.*
import com.intellij.patterns.PsiJavaPatterns
import com.intellij.patterns.PlatformPatterns
def ctx = context(
ctype: PsiJavaPatterns.psiClass().withName(PlatformPatterns.string().matches(/.*/))
)
contributor(ctx) {
def path = ""
try {