Skip to content

Instantly share code, notes, and snippets.

View phillro's full-sized avatar

Phillip Rosen phillro

View GitHub Profile
{"name": "currency", "type": "Currency"},
{"name": "text", "type": "Text"},
{"name": "percent", "type": "Percent"},
{"name": "number", "type": "Number"},
{"name": "date_time", "type": "DateTime"}
import org.json4s._
import org.json4s.jackson.Serialization
import org.json4s.jackson.Serialization.read
import org.json4s.{NoTypeHints, Formats}
import org.json4s.ext.EnumSerializer
import org.scalatest.{GivenWhenThen, FlatSpec}
import org.scalatest.matchers.ShouldMatchers
ava.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:209)
at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:180)
at org.rosuda.REngine.Rserve.RConnection.assign(RConnection.java:283)
at com.orchard.noteserver.models.RServeModelQuery.apply(RServeModelQuery.scala:45)
at com.orchard.noteserver.ModelCalculationActor$$anonfun$receive$3.applyOrElse(RootActor.scala:103)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498)
{\"Message\":\"An error has occurred.\",\"ExceptionMessage\":\"The operation cannot be completed because the DbContext has been disposed.\",\"ExceptionType\":\"System.InvalidOperationException\",\"StackTrace\":\" at System.Data.Entity.Internal.InternalContext.CheckContextNotDisposed()\\r\\n at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()\\r\\n at System.Data.Entity.Internal.Linq.InternalQuery`1.GetEnumerator()\\r\\n at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.IEnumerable.GetEnumerator()\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\\r\\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
@phillro
phillro / gist:8656128
Created January 27, 2014 20:00
fuck you slick
select x2.x3, x2.x4, x2.x5, x2.x6, x2.x7, x2.x8, x2.x9, x2.x10, x2.x11, x2.x12, x2.x13, x2.x14, x2.x15, x2.x16, x2.x17, x2.x18, x2.x19, x2.x20, x2.x21, x2.x22, x2.x23, x2.x24, x2.x25, x2.x26, x27.x28, x27.x29, x27.x30, x27.x31, x27.x32 from (select x33.x34 as x3, x33.x35 as x4, x33.x36 as x5, x33.x37 as x6, x33.x38 as x7, x33.x39 as x8, x33.x40 as x9, x33.x41 as x10, x33.x42 as x11, x33.x43 as x12, x33.x44 as x13, x33.x45 as x14, x33.x46 as x15, x47.x48 as x16, x47.x49 as x17, x47.x50 as x18, x47.x51 as x19, x47.x52 as x20, x47.x53 as x21, x47.x54 as x22, x47.x55 as x23, x47.x56 as x24, x47.x57 as x25, x47.x58 as x26 from (select x59.x60 as x34, x59.x61 as x35, x59.x62 as x36, x59.x63 as x37, x59.x64 as x38, x59.x65 as x39, x59.x66 as x40, x59.x67 as x41, x68.x69 as x42, x68.x70 as x43, x68.x71 as x44, x68.x72 as x45, x68.x73 as x46 from (select x74."id" as x60, x74."name" as x61, x74."script" as x62, x74."model_type" as x63, x74."date_range_low" as x64, x74."date_range_high" as x65, x74."created_at" as x66,
def getOneStuffWithThings(stuffId: Long, accountId: Long):ParentCaseClass = {
val suffWithThings = db.withSession {
implicit s: Session =>
val q1 = Stuff
.filter(_.id === stuffId)
.filter(_.accountId === accountId)
.leftJoin(OtherRelatedStuff).on(_.otherRelatedStuffId === _.id)
.leftJoin(MoreRelatedStuff).on(_._2.moreRelatedStuffId === _.id)
.map {
case ((stuff, otherRelatedStuff), MoreRelatedStuff) => {
abstract class Tree
case class Sum(l: Tree, r: Tree) extends Tree
case class Var(n: String) extends Tree
case class Const(v: Int) extends Tree
type Environment = String => Int
def eval(t: Tree, env: Environment): Int = t match {
case Sum(l, r) => eval(l, env) + eval(r, env)
case Var(n) => env(n)
MONGO = {
"INSIGHTS": {
'CONNECTIONS': [{
"host": "prod-mongo-s1.p.offerpop.com",
"port": 27017
}],
"DBNAME": "insights_test",
}
}
module.exports = {
'development':{
'port':3000,
'workers':1,
"mongo":{
"dbName":"m0",
"port":27017,
"host":"ec2-23-20-128-115.compute-1.amazonaws.com",
},
"redis":{
module.exports = function convertDots(input){
var obj={}
Object.keys(input).forEach(function(k){
var val = typeof input[k]=='object' && !(input[k] instanceof Array) ? convertDots(input[k]) : input[k];
var parts = k.split('.');
obj[parts[0]]=(function nestIt(parts, v){
return parts.length==1 ? (function(){
var r={};
r[parts[0]]=v;
return r;