Skip to content

Instantly share code, notes, and snippets.

View 0xRoch's full-sized avatar
🎯
Focusing

Roch 0xRoch

🎯
Focusing
View GitHub Profile
@()(
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>
}
@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++) {
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;
}
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();
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
Map<String, Integer> counter = new HashMap<String, Integer>();
for (Item item : aa) {
counter.put(item.name, 1);
}
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>();
@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.*;
def renderList = {
".GsImageBox *" #> page.map(outfit => {
".outfit-thumb [href]" #> outfit.url() &
".thumb [alt]" #> outfit.toString() &
".thumb [src]" #> outfit.thumbUrl() &
".views-count *" #> outfit.view
})
}
<?php
function sendMemcacheCommand($command){
$server = "localhost";
$port = 11211;
$s = @fsockopen($server,$port);
if (!$s){
die("Cant connect to:".$server.':'.$port);