Skip to content

Instantly share code, notes, and snippets.

@With({ETagAdder.class, GZipCompression.class})
public class Application extends Controller {
@CacheFor(value="5min")
public static void doSomething(){
//...
render();
}
}
#include "ofApp.h"
#include <csetjmp>
class Continuation{
public:
Continuation() : done(false), jumped(false){}
bool work(){
if( done ) return true;
@kritzikratzi
kritzikratzi / Assembler.java
Created September 19, 2012 15:29
Re-assembling the "click and drag" xkcd comic
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
@kritzikratzi
kritzikratzi / RefreshJob.java
Created February 11, 2012 16:04
Parsing wikipedia is funky ...
package jobs;
import static utils.MWUtils.fetch;
import static utils.MWUtils.findReferences;
import static utils.MWUtils.getTagParameter;
import static utils.MWUtils.removeLinks;
import static utils.MWUtils.clean;
import static utils.MWUtils.findHeadlines;
import java.util.ArrayList;
@kritzikratzi
kritzikratzi / ExampleController.java
Created November 19, 2011 18:58
Play pagination
class ExampleController{
public static void search( String query, String someParam, int page ){
// get search results ...
// usually you end up with this:
int total = ... // total number of results
List<Item> results, = ... // subset of results
// now create pagination info
PaginationInfo paginationInfo = new PaginationInfo(
@kritzikratzi
kritzikratzi / gist:1275443
Created October 10, 2011 14:23
How I could imagine a more useful blobs class ...
Usage:
public class MyModel extends ...{
@Reference
public static List<Blob2> images;
@Reference
@kritzikratzi
kritzikratzi / gist:1275419
Created October 10, 2011 14:08
Another way to use play-morphia blobs
package models;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import play.libs.MimeTypes;
import play.modules.morphia.Blob;
@kritzikratzi
kritzikratzi / gist:1238410
Created September 23, 2011 20:52
97 simple steps to get a working eclipse url handler for play in mac os

I really like those links to be clickable from my web-browser, I also really love eclipse.

Here's how you make them play together:

1/97: Modify your application.config

/******************************************************************************
* *
* PROJECT : EOS Digital Software Development Kit EDSDK *
* NAME : EDSDKErros.h *
* *
* Description: ERROR DEFINITION FOR EDSDK *
* *
*******************************************************************************
* *
* Written and developed by Canon Inc. *
package org.sd.doodle.server.lib
import org.sd.doodle.server.model.DrawingModel
import net.liftweb.http.{Req, GetRequest, PostRequest,
LiftRules, JsonResponse, PlainTextResponse, XmlResponse}
import net.liftweb.util.Helpers
import net.liftweb.common._
import net.liftweb.http.js.JE._
import net.liftweb.mapper._