ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install caskroom/cask/brew-cask
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.time.LocalDate | |
| import java.time.temporal.TemporalAdjusters | |
| LocalDate localDate = LocalDate.now() | |
| println localDate // 2016-04-12 | |
| println localDate.plusMonths(1).withDayOfMonth(1) // 2016-05-01 | |
| println localDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()) // 2016-03-31 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.time.LocalDate | |
| import java.time.ZonedDateTime | |
| import java.time.ZoneId | |
| import java.time.format.DateTimeFormatter | |
| import java.time.temporal.TemporalAdjusters | |
| // If you have a date without time information, use a LocalDate. e.g. someone's birthday | |
| LocalDate localDate = new LocalDate(2016, 4, 12) | |
| println localDate.toString() // 2016-04-12 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.foo.config | |
| import com.foog.util.TomcatDatasourceUtil | |
| import grails.plugins.rest.client.RestBuilder | |
| import groovy.json.JsonSlurper | |
| /** | |
| * Application service to get and set values from a centralized remote configuration service. | |
| */ | |
| class RemoteConfigService { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import groovy.json.JsonSlurper | |
| dataSource { | |
| // most properties are directly set | |
| pooled = true | |
| // ... | |
| // the url is retrieved from etcd...make sure the etcd resource is properly protected | |
| def jsonSlurper = new JsonSlurper() | |
| def catalogUrlConfig = jsonSlurper.parseText(new URL("http://etcdlocation:2379/v2/keys/dataSource/url").text) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.foo.util | |
| import groovy.util.logging.Log4j | |
| import org.apache.tomcat.jdbc.pool.ConnectionPool | |
| import org.codehaus.groovy.grails.commons.GrailsApplication | |
| @Log4j | |
| class TomcatDatasourceUtil { | |
| static void ensureCurrentDatasources(GrailsApplication application, List datasourceNames) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def things = null | |
| things.collect { it.a } // returns [] | |
| things*.a // returns null | |
| things.a // throws a NullPointerException | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def things = [ [a: 1], [a: 2] ] | |
| things.collect { it.a } // returns [1, 2] | |
| things*.a // returns [1, 2] | |
| things.a // returns [1, 2] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <%@ page defaultCodec="none" %> | |
| <div class="form-group ${formGroupClass ?: ''} <g:if test="${invalid}">has-error</g:if>"> | |
| <label class="control-label ${labelClass ?: ''}" for="${property}">${label} <%=required ? "*" : ""%></label> | |
| <input type="<%=type ?: "text" %>" name="${prefix ?: ''}${property}" id="${prefix ?: ''}${property}" value="${value}" <%=constraints.maxSize ? "maxlength=${constraints.maxSize}" : ""%> <%=readonly ? "readonly=readonly" : ""%> class="form-control <%= pageScope["class"] ?: '' %>" <%=placeholder ? "placeholder='$placeholder'" : ""%>/> | |
| <g:if test="${helpText}"><span class="help-block">${helpText}</span></g:if> | |
| <g:if test="${invalid}"><span class="help-block">${errors.join('<br>')}</span></g:if> | |
| </div> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package myapp | |
| import org.apache.commons.logging.Log | |
| import org.apache.commons.logging.LogFactory | |
| import org.apache.log4j.MDC | |
| class UsageTrackingFilters { | |
| private static final Log LOG = LogFactory.getLog('usagetracking') | |
| private static final String REQUEST_ID = "requestId" |