Skip to content

Instantly share code, notes, and snippets.

View 0xRoch's full-sized avatar
🎯
Focusing

Roch 0xRoch

🎯
Focusing
View GitHub Profile
@0xRoch
0xRoch / gist:2585490
Created May 3, 2012 13:08
GAE BLOB BINDER
package models;
import java.lang.annotation.*;
import java.lang.reflect.Type;
import java.util.List;
import com.google.appengine.api.datastore.Blob;
import play.data.Upload;
import play.data.binding.*;
protected static void incrementValue(Map<Long, Integer> counters, Long toAdd) {
Integer currValue = counters.get(toAdd);
if (currValue == null)
counters.put(toAdd, 1);
else
counters.put(toAdd, currValue+1);
}
Map<String, Integer> counter = new HashMap<String, Integer>();
Map<String, Integer> counter = new HashMap<String, Integer>();
for (Item item : aa) {
counter.put(item.name, 1);
}
package controllers
import java.io.StringReader
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
import models.Contact
import org.w3c.dom.Document
import org.xml.sax.InputSource
import play.cache.Cache
import play.libs.OAuth
Calendar cal = new GregorianCalendar();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_YEAR,-1);
Date oneDayBefore= cal.getTime();
List<User> users = all().filter("lastSeen>", oneDayBefore).fetch();
public static List<User> findByLocation(Long South_Lat, Long South_Lng, Long North_Lat, Long North_Lng) {
List<User> users = all().filter("latitude<", South_Lat).filter("latitude>", North_Lat).filter("latitude>", North_Lat).filter("longitude>", North_Lng).fetch();
return users;
}
@Override
public void get(final Object obj) {
List<Object> res = null;
try {
Class<?> clazz = obj.getClass();
ClassInfo info = ClassInfo.getClassInfo(clazz);
final String[] fields = new String[info.updateFields.size()];
for (int i = 0; i < info.updateFields.size(); i++) {
@()(
implicit
params:play.mvc.Scope.Params,
flash:play.mvc.Scope.Flash,
errors:Map[String,play.data.validation.Error]
)
@import play.i18n.Messages
@main(title = "Test title") {
<p>Hello world in &{'english'}</p>
}
<?xml version="1.0" ?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>My SuperCool Application powered by Playframework</display-name>
<context-param>
<param-name>play.id</param-name>
//form.html
#{list items:_fields ?: currentType.fields*.name, as:'fieldName'}
%{x++}%
<div id="${x}" style="height: 20px;">
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#${x}').load('@{CRUD.loadField(fieldName)}');
});
</script>