Skip to content

Instantly share code, notes, and snippets.

View oxlade39's full-sized avatar

Dan Oxlade oxlade39

View GitHub Profile
@oxlade39
oxlade39 / gist:426611
Created June 5, 2010 13:09
telling sbt to use local maven repo
class Project(info: ProjectInfo) extends DefaultWebProject(info) {
val mavenLocal = "Local Maven Repository" at "file:///"+Path.userHome+"/.m2/repository"
}
package org.doxla.junit4;
import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
// where ten().getValue() returns the Integer 10 in 200 millis
@Test public void withoutEventuallyWeGetNull() throws Exception {
assertThat(ten().getValue(), nullValue());
}
@Test public void withEventuallyICanAssertWhatTheValueWillEventuallyReturn() throws Exception {
assertThat(eventually(ten()).getValue(), willReturn(10));
}
var sys=require('sys'), http = require('http');
var connection = http.createClient(80, "search.twitter.com");
function TweetSearcher(search, pollTime, newTweetEventHandler) {
this.search = search;
this.pollTime = pollTime;
this.since = 0;
this.newTweet = newTweetEventHandler
}
@oxlade39
oxlade39 / TradingStrategy.scala
Created January 24, 2011 21:04
akka FSM bug?
package org.doxla.privet.akka.strategy.simple
import akka.actor.{Actor, ActorRef, FSM}
import akka.actor.FSM._
import akka.util.duration._
import org.doxla.privet.akka.bet._
sealed trait TradingState
case object NoBetsPlaced extends TradingState
case object BackPlaced extends TradingState
curl --data "days=0&format=bleb&channels=bbc1,bbc2,itv1,ch4,five,4music,bbc1ènèireland,bbc1èscotland,bbc1èwales,bbc2ènèireland,bbc2èscotland,bbc2èwales,bbc3,bbc4,bbc7,bbcè6music,bbcèhd,bbcènews24,bbcèparliament,bbcèradio1,bbcèradio1èxtra,bbcèradio2,bbcèradio3,bbcèradio4,bbcèradio5èlive,bbcèradio5èliveèsportsèextra,bbcèradioèscotland,bbcèworldèservice,boomerang,bravo,britishèeurosport,cartoonènetwork,cbbc,cbeebies,challenge,citv,dave,discovery,discoveryèrealètime,disney,e4,extremeèsports,filmèfour,fiveèus,fiver,fx,idealèworld,itv2,itv3,itv4,livingètv,menèandèmotors,more4,mtv,nickèjunior,nickelodeon,oneword,paramount,paramount2,qvc,s4c,s4c2,scifi,skyèmoviesèactionèthriller,skyèmoviesèclassics,skyèmoviesècomedy,skyèmoviesèdrama,skyèmoviesèfamily,skyèmoviesèhd1,skyèmoviesèhd2,skyèmoviesèindie,skyèmoviesèmodernègreats,skyèmoviesèpremiere,skyèmoviesèsci-fièhorror,skyènews,skyèone,skyèsports1,skyèsports2,skyèsports3,skyèsportsènews,skyèsportsèxtra,skyèthree,skyètravel,skyètwo,tcm,teachersètv,tmf,ukègold,uktvèstyle,v
import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info)
{
val sbtGitHubPlugin = "com.github.oxlade39" % "sbt-github-plugin" % "2.0.1" from "http://cloud.github.com/downloads/oxlade39/sbt-github-plugin/sbt-github-plugin-2.0.1.jar"
}
object HomepageSpec extends ScalatraSpecification {
addFilter(classOf[ScalatraEntrypoint], "/*")
"Homepage" should {
"respond to GET /" in {
get("/") {
status mustEqual(200)
}
}
@oxlade39
oxlade39 / PartialFunctionSpec.scala
Created April 3, 2012 07:41
Example showing unexpected behaviour from a PartialFunction
class ScalaSpec extends FlatSpec with MustMatchers {
behavior of "a PartialFunction"
it should "chain" in {
var pf: PartialFunction[String, String] = {
case "1" => "2"
}
pf = pf andThen {
@oxlade39
oxlade39 / new-post.scala
Created April 17, 2012 07:21
Generate a new Jekyll post file
#!/usr/bin/env scala
!#
JekyllBlogPost.createFile
object JekyllBlogPost {
import java.io.File
import java.io.FileWriter
import java.util.Date