Skip to content

Instantly share code, notes, and snippets.

Erik Fried erikfried

Block or report user

Report or block erikfried

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 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 Aug 29, 2015
Example of pulse2 tracking for a plus article page
View pulse2_premium_page_tracking.json
[
{
"@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 Aug 29, 2015
Example of pulse2 tagging of section page
View pulse2_section_page_0.2.json
[
{
"@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 Dec 30, 2015
Spid api object
View user.json
{
"name": "SPPContainer",
"version": "0.2",
"api": 2,
"object": "User",
"type": "element",
"code": 200,
"request": {
"reset": 3571,
"limit": 0,
@erikfried
erikfried / README.md
Last active Dec 22, 2015
Run tests locally with sbt in maven project.
View README.md

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 Jun 3, 2013
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>
View Controller.scala
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 Apr 9, 2013
Test/spike implementation of api client for spid with Jersey.
View SpidJerseyApi.java
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 Oct 3, 2012
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
View yuiconfigreuse.js
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"
}
},
View Build.scala
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 Feb 29, 2012
Java scala collections comparison
View example.java
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;
}
You can’t perform that action at this time.