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 / pulse2_premium_page_tracking.json
Last active August 29, 2015 14:23
Example of pulse2 tracking for a plus article page
[
{
"@context": [
"http://www.w3.org/ns/activitystreams",
{
"spt": "http://schibsted.com",
"spt:sdkType": "JS",
"spt:sdkVersion": "0.3.0"
}
],
@erikfried
erikfried / pulse2_section_page_0.2.json
Last active August 29, 2015 14:23
Example of pulse2 tagging of section page
[
{
"@context": [
"http://www.w3.org/ns/activitystreams",
{
"spt": "http://schibsted.com",
"spt:sdkType": "JS",
"spt:sdkVersion": "0.3.0"
}
],
@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 / 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;
}