Skip to content

Instantly share code, notes, and snippets.

View coderberry's full-sized avatar

Eric Berry coderberry

View GitHub Profile
@coderberry
coderberry / ExampleController.groovy
Created April 17, 2012 17:29
ExampleController.groovy
class ExampleController {
def splitTestService
def almostConverted() {
// Mark split test as converting on Action 1
splitTestService.markTestAsActionOneConverted('My First Split Test')
// Mark split test as converting on Action 2
splitTestService.markTestAsActionTwoConverted('My First Split Test')
@coderberry
coderberry / BootStrap.groovy
Created April 27, 2012 02:14
BootStrap.groovy
import com.example.Role
import com.example.User
class BootStrap {
def shiroSecurityService
def init = { servletContext ->
// Create the admin role
def adminRole = Role.findByName('ROLE_ADMIN') ?:
@coderberry
coderberry / FoundationTagLib.groovy
Created May 6, 2012 14:45
FoundationTagLib.groovy
package com.groovyflow
import org.springframework.web.servlet.support.RequestContextUtils
class FoundationTagLib {
static namespace = "foundation"
Closure paginate = { attrs ->
def writer = out
if (attrs.total == null) {
@coderberry
coderberry / BuildConfig.groovy
Created May 21, 2012 18:38
BuildConfig.groovy
dependencies {
runtime 'postgresql:postgresql:9.1-901-1.jdbc4'
}
plugins {
runtime ":hibernate:$grailsVersion",
":jquery:1.7.1",
":resources:1.1.6",
":spring-security-core:1.2.7.3",
":taggable:1.0.1",
@coderberry
coderberry / Table.sublime-snippet
Created July 2, 2012 15:20
type 'tab' in sublime text to generate a full table with thead and tbody
<snippet>
<content><![CDATA[
<table>
<thead>
<tr>
<th>${1:}</th>
</tr>
</thead>
<tbody>
<tr>
@coderberry
coderberry / w2-e1.rb
Created August 23, 2012 02:10
w2-e1.rb
>> x = 1 # Assigns the variable x with the value of 1
=> 1
>> y = 2 # Assigns the variable y with the value of 2
=> 2
>> z = x + y # Assigns the sum of x and y to the variable z
=> 3
@coderberry
coderberry / w2-e2.rb
Created August 23, 2012 02:12
w2-e2.rb
>> first_name = "Eric"
=> "Eric"
>> last_name = 'Berry'
=> "Berry"
>> first_name + " " + last_name
=> "Eric Berry"
@coderberry
coderberry / w2-e3.rb
Created August 23, 2012 02:14
w2-e3.rb
>> cost_per_taco = 0.85
=> 0.85
>> taco_count = 3
=> 3
>> total_cost = cost_per_taco * taco_count
=> 2.55
>> cost_per_taco.class
=> Float
>> taco_count.class
=> Fixnum
@coderberry
coderberry / w2-e4.rb
Created August 23, 2012 02:15
w2-e4.rb
>> x = true
=> true
>> y = false
=> false
>> x == y # is x equal to y? This is what the == operand does
=> false
>> eric_age = 35
=> 35
>> josh_age = "35"
@coderberry
coderberry / w2-e5.rb
Created August 23, 2012 02:31
w2-e5.rb
>> hand = [ 'Ace', 'Jack', 'Queen', 'King' ]
=> ["Ace", "Jack", "Queen", "King"]
>> hand.class
=> Array
>> hand[2] # return the value at the 2nd index (3rd item)
=> "Queen"