Skip to content

Instantly share code, notes, and snippets.

View aruizca's full-sized avatar

Angel Ruiz aruizca

View GitHub Profile
@aruizca
aruizca / JSONObjectNullSpec.groovy
Created July 28, 2015 00:35
This shows the problems with the use of the JSONObject.NULL class by the Grails JSON converter
package grails.converters.tests
import grails.converters.JSON
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
import spock.lang.Specification
/**
* Created by Angel Ruiz.
*/
class JSONObjectNullSpec extends Specification {
@aruizca
aruizca / snippet.groovy
Created July 29, 2015 23:49
Monad example from Mario Fusco's "Monadic Java" presentation but implemented in Groovy
String getCarInsuranceName(Person person) {
String insuranceName = person?.getCar()?.getInsurance()?.getName()
return insuranceName?:"Unknown"
}
@aruizca
aruizca / gist:5079807
Created March 4, 2013 03:57
AjaxAnywhere taglib declaration
<%@ taglib uri="http://com.nerderg/ajaxanywhere" prefix="aa" %>
@aruizca
aruizca / gist:5079302
Created March 4, 2013 01:29
Ajaxify form with AjaxAnywhere
<form action="${action}" method="post" aa-refresh-zones="aaZone1Example1, aaZone2Example1">
@aruizca
aruizca / gist:5079390
Created March 4, 2013 01:59
Ajaxify submit elements within a form
<form ....>
...
<div>
<button type="submit" aa-refresh-zones="aaZone1Example2" class="btn btn-primary" name="refreshTextButton" value="Refresh Text">Refresh Text</button>
<input type="image"aa-refresh-zones="aaZone1Example2" src="<c:url value="/img/refresh.png"/>" name="refreshTextButton" value="Refresh Text"/>
<input type="submit" aa-refresh-zones="aaZone2Example2" class="btn btn-info" name="showCodeButton" value="Show Code"/>
</div>
</form>
@aruizca
aruizca / gist:5079417
Last active December 14, 2015 11:29
Ajaxify select element
<form ...>
...
<sf:select path="continentCode" aa-refresh-zones="countryZone, capitalZone" id="continentCode">
<sf:option value="">-- Select One --</sf:option>
<sf:options items="${countryForm.continentsSet}" itemLabel="value" itemValue="key"/>
</sf:select>
...
</form>
@aruizca
aruizca / gist:5079674
Created March 4, 2013 03:21
Ajaxify link elements
<a href="<c:url value="/action/examples/4?data=whatever"/>" aa-refresh-zones="codeLayer4">Show Code</a>
@aruizca
aruizca / gist:5079843
Created March 4, 2013 04:10
Mark refresh zones in JSP
<aa:zone id="myZone">
<!-- Zone Content -->
...
</aa:zone>
@aruizca
aruizca / gist:5079938
Last active December 14, 2015 11:29
AjaxAnywhere Maven dependency
<dependency>
<groupId>com.nerderg.ajaxanywhere</groupId>
<artifactId>ajaxanywhere</artifactId>
<version>2.0</version>
</dependency>
@aruizca
aruizca / gist:5080167
Created March 4, 2013 05:33
AjaxAnywhere static file resolution
<servlet>
<servlet-name>AAResourcesServlet</servlet-name>
<servlet-class>com.nerderg.ajaxanywhere.servlet.StaticResourcesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AAResourcesServlet</servlet-name>
<url-pattern>/js/jquery-aa.js</url-pattern>
</servlet-mapping>