Skip to content

Instantly share code, notes, and snippets.

package com.ticketfly.pillage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class LogfileReporter implements StatsReporter {
@bigtoast
bigtoast / Shell
Last active December 11, 2015 23:18
# to install the latest stable version:
brew install play
# to install play-2.1-RC3:
# if you already have a version of play installed you will need to unlink it.
brew unlink play
brew install https://raw.github.com/gist/4675514/play.rb
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch play 2.0.4
@bigtoast
bigtoast / HttpServer.scala
Created October 24, 2012 09:30 — forked from sheki/HttpServer.scala
httpFINAGLE
import com.twitter.finagle.http.path._
import com.twitter.finagle.http.service.RoutingService
import com.twitter.finagle.http.{Request, Response, RichHttp, Http}
import com.twitter.finagle.{Service, SimpleFilter}
import org.jboss.netty.handler.codec.http._
import org.jboss.netty.handler.codec.http.HttpResponseStatus._
import org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1
import org.jboss.netty.buffer.ChannelBuffers.copiedBuffer
import org.jboss.netty.util.CharsetUtil.UTF_8
import com.twitter.util.Future
@bigtoast
bigtoast / FutureLeak.scala
Created May 23, 2012 00:19
Leaking mutable state into a future..
import akka.actor._
import akka.dispatch._
import akka.pattern.pipe
trait StuffService {
type Stuff
def doStuff :Future[Stuff]
}
case object DoStuff
@bigtoast
bigtoast / diva shit plan
Created February 29, 2012 06:58
plan when diva shit hits the fan
find open files from diva
sudo lsof -u j2ee-dva
on db machine.
mysql -e "show processlist" | grep diva | wc -l
sudo netstat -lptu
@bigtoast
bigtoast / coordinationexample.scala
Created January 18, 2012 01:40
coordination example
class AvailablePool extends Actor {
var coordinationSequence = 0
var allocatorSequence = 0
var pool = 100
def receive = {
case Get(count, coordSeq) if count <= pool =>
if ( coordSeq >= coodinationSequence )
@bigtoast
bigtoast / sampleconfigslurper.groovy
Created October 18, 2011 23:14
ConfigSluper for groovy
// create a file called datasources.config somewhere
// put in something like this
/*
datasource {
user = "atd"
pass = "chubs"
host = "localhost"
// yada yada
@bigtoast
bigtoast / groovySqlSetup.groovy
Created October 18, 2011 23:02
groovy sql setup
import groovy.sql.*
// jdbc config properties
// http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html
// make sure your mysql driver is on the classpath
def uname = ""
def password = ""
def genDbName( String name ) { name + "_" + (new Date()).getTime() }
def dbname = genDbName("mytest")
@bigtoast
bigtoast / gist:1154501
Created August 18, 2011 16:47 — forked from arjanblokzijl/gist:1141567
sbt10 - generated sources
import sbt._
import sbt.Keys._
object build extends Build {
lazy val generate = Project(
id = "source-gen",
base = file("."),
settings = Defaults.defaultSettings ++ generateSourceSettings
)
@bigtoast
bigtoast / gist:1150325
Created August 16, 2011 22:12
dates with jodatime datetime
var org_date_created;
var org_date_of_sale;
// zones ( local is for dev environments
local = org.joda.time.DateTimeZone.getDefault();
cenZone = org.joda.time.DateTimeZone.forID('America/Chicago');
// dates from db in central
dc = (new org.joda.time.DateTime( date_created )).withZoneRetainFields(cenZone);
dos = (new org.joda.time.DateTime( date_of_sale )).withZoneRetainFields(cenZone);