Skip to content

Instantly share code, notes, and snippets.

View erikfried's full-sized avatar

Erik Fried erikfried

View GitHub Profile
@erikfried
erikfried / BoomerangVelvetMetrics.html
Created March 2, 2011 13:38
A very simple test, using velvetmetrics as reporting backend to boomerang
<!DOCTYPE html>
<html>
<head>
<title>Velvet test with BOOMR</title>
</head>
<body>
<h1>Testing roundtrip time</h1>
<p>Using <a href="http://developer.yahoo.com/blogs/ydn/posts/2010/06/performance_testing_with_boomerang/">Boomerang</a> and <a href="http://www.velvetmetrics.com/">velvetmetrics</a></p>
<p id="results"></p>
<img src="http://www.velvetmetrics.com/chart?&path=random.path.3yb8s&groupBy=10min&f=avg&datapoints=true&title=true&axes=true&legends=true&customtitle=Avg%20roundtrip%20time%20/10%20mins&w=600&h=250&output=image&rand=2612" alt="loadtime history"/>
@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 / MyModule.js
Created July 1, 2011 09:51
Testing YUI3 modules with Jasmine
YUI.add("my-module", function (Y) {
Y.namespace("mynamespace");
Y.mynamespace.MyModule = function () {
return {hello : "hello"};
};
}, '0.0.1' /*version*/, {
requires : ["base"]
});
@erikfried
erikfried / gist:1067011
Created July 6, 2011 11:05 — forked from remy/gist:350433
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@erikfried
erikfried / alert.js
Created November 28, 2011 21:39
alert
alert("This is just an alert to prove I´ve been executed");
@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 / 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;
}
@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 / 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 / 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;