Skip to content

Instantly share code, notes, and snippets.

View erikfried's full-sized avatar

Erik Fried erikfried

View GitHub Profile
@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:

@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 / 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 / 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 / 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 / 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 / README.markdown
Created March 7, 2011 10:21
shell script to invoke jslint via jsc on Mac OS X

I just realized that there is a rather well hidden javascript interpreter in the mac os x terminal out of the box. /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc See http://www.phpied.com/javascript-shell-scripting/

Then i figured it coud be quite easy to set up a command line util to run jslint from anywhere. Thought i´d share how.

Setup

@erikfried
erikfried / yuiconfigreuse.js
Created October 3, 2012 19:45
Some YUI3 components, e g AutoComplete or Charts, have a lot of config to set up general look-and-feel, that you typically wish to reuse throughout the application. I have not found out a satisfying way to reuse such config. For instance, extending the C
YUI().use('charts', function (Y) {
//Some config that i want to reuse for more or less all charts in my application
var defaultConfig = function () {
return {
categoryType: "time",
axes: {
category: {
labelFormat: "%e %b"
}
},
@erikfried
erikfried / Build.scala
Created March 22, 2012 14:25
Play2 build file
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "my_app"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
@erikfried
erikfried / example.java
Created February 29, 2012 08:56
Java scala collections comparison
public List<Integer> getContinuousLessThan150DaysOfferIds(List<DbLegacyOffer> list){
List<Integer> retList = new ArrayList<Integer>();
for(DbLegacyOffer offer : list) {
if(offer.isBecomesContinous() && offer.getLength() < 150)
retList.add(offer.getOfferId());
}
return retList;
}