Skip to content

Instantly share code, notes, and snippets.

View mstine's full-sized avatar

Matt Stine mstine

View GitHub Profile
security {
// see DefaultSecurityConfig.groovy for all settable/overridable properties
active = true
loginUserDomainClass = "com.mattstine.wendysstore.domain.User"
authorityDomainClass = "com.mattstine.wendysstore.domain.Role"
useRequestMapDomainClass = false
public class AuthFilters {
def authenticateService
def filters = {
blurbCheck(controller: 'blurb') {
before = {
if (authenticateService.ifAllGranted('ROLE_ADMIN')) {
import org.codehaus.groovy.grails.plugins.springsecurity.Secured
@Secured(['ROLE_ADMIN'])
class ProductController {
//...
}
@Secured(['ROLE_ADMIN'])
def create = {
controllerAnnotationStaticRules = [
'/blurb/**': ['ROLE_ADMIN'],
‘/setting/**’: ['ROLE_ADMIN']
]
<script language="JavaScript">
document.write("<SCR" + "IPT SRC='" + ez_codePath + "ezloader.js'><\/SCR" + "IPT>");
</script>
@mstine
mstine / Lucky13.java
Created December 10, 2010 04:55
Solution to Lucky 13 Contest
import org.codehaus.jackson.map.ObjectMapper;
import java.util.Map;
import java.net.URL;
import java.io.*;
public class Lucky13 {
public int pay(int bet) throws Exception {
return new ObjectMapper().readValue(new BufferedReader(new InputStreamReader(new URL("http://roulette.engineyard.com/")
.openStream())).readLine(), Map.class).get("winning_number").equals("13") ? 35 * bet : 0;
}
@mstine
mstine / gist:4962020
Created February 15, 2013 17:45
The problem child...all of the classes are making it in to the "uberJar," but the resources are not.
task uberJar(type: Jar) {
baseName = "foo-cacheserver-uberjar"
from {
sourceSets.main.output.classesDir
sourceSets.main.output.resourcesDir
configurations.compileNoGemFire.collect { it.isDirectory() ? it : zipTree(it) }
}
}
@Configuration
@PropertySource("classpath:application.properties")
public class AppConfig {
@Autowired
private Environment env;
@Bean
public DriverManagerDataSource dataSource() {
final DriverManagerDataSource driverManagerDataSource =
@mstine
mstine / gist:8061861
Created December 20, 2013 21:29
AppFirst + CF Release 151 on vSphere
---
name: test
director_uuid: 46beb722-f241-4419-a0b5-dcba70805116
releases:
- name: lite
version: 151.9-dev
networks:
- name: default
@mstine
mstine / conc.go
Created February 24, 2014 22:38
Go port of NAV calculation from Ch. 2 of Programming Concurrency on the JVM
package main
import (
"bufio"
"errors"
"fmt"
"net/http"
"os"
"strconv"
"strings"