Skip to content

Instantly share code, notes, and snippets.

View erikfried's full-sized avatar

Erik Fried erikfried

View GitHub Profile
@erikfried
erikfried / SpidJerseyApi.java
Created April 9, 2013 12:43
Test/spike implementation of api client for spid with Jersey.
package no.spp.sdk.client;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientHandler;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
@erikfried
erikfried / Controller.scala
Created June 3, 2013 21:06
Automagic content negotiation with playframework (version >= 2.1). If called with Accept: application/json => { "firstName": "Erik", "surName": "Fried", "age": 34 } Accept: text/xml => <person> <firstName>Erik</firstName> <surName>Fried</surName> <age>34</age> </person>
package controllers
import play.api.mvc._
import play.api.libs.json.{Writes, Json}
import test.PersonRepository
import scala.xml.Elem
object PersonResource extends Controller with ContentNegotiation {
@erikfried
erikfried / README.md
Last active December 22, 2015 10:59
Run tests locally with sbt in maven project.

What does sbt have that maven does not?

  1. Continuous compilation, that is files are compiled and tested upon file change. Just run any target with ~, eg sbt ~test
  2. Sheer speed. The full test execution takes about half the time compared to maven.
  3. test-quick - An sbt target that only runs tests that either a) failed in the previous run b) have not run before or c) Have recompiled dependencies.

How?

@erikfried
erikfried / user.json
Last active December 30, 2015 20:39
Spid api object
{
"name": "SPPContainer",
"version": "0.2",
"api": 2,
"object": "User",
"type": "element",
"code": 200,
"request": {
"reset": 3571,
"limit": 0,
@erikfried
erikfried / JaxRsResource.java
Created February 24, 2012 10:10
Comparison Java + JAX-RS vs. Java + Playframework 2 vs. Scala + Playframework 2
package se;
import com.sun.jersey.api.NotFoundException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.EntityTag;
@erikfried
erikfried / keybase.md
Created June 16, 2017 10:40
keybase.md

Keybase proof

I hereby claim:

  • I am erikfried on github.
  • I am scherik (https://keybase.io/scherik) on keybase.
  • I have a public key ASA5cBD0kmd-tw_Bxh4rJdq5lQpgcQa7EzoSJlTk5-t1fQo

To claim this, I am signing this object: