This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- all json objects | |
| select field_id, | |
| parcel_tags, ranch_tags, aggregated_values from event_queries | |
| where field_id in | |
| (select field_id from event_queries limit 10); | |
| -- all json keys | |
| select distinct json_object_keys(parcel_tags) as keys | |
| from event_queries | |
| where field_id in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scalikejdbc._ | |
| import scalikejdbc.config._ | |
| import scalaz._, Scalaz._ | |
| import argonaut._, Argonaut._ | |
| GlobalSettings.loggingSQLAndTime = new LoggingSQLAndTimeSettings( | |
| enabled = true, | |
| singleLineMode = true, | |
| logLevel = 'DEBUG | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import shapeless._ | |
| import spray.routing._ | |
| import Directives._ | |
| val realHost: Directive1[String] = | |
| (optionalHeaderValueByName("X-Host") & headerValueByName("Host")).hmap { | |
| case xhost :: host :: HNil => xhost.getOrElse(host) | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import dispatch._, Defaults._ | |
| import scala.concurrent._, scala.concurrent.duration._ | |
| val svc = dispatch.url("http://casoilresource.lawr.ucdavis.edu/gmap/get_mapunit_data.php") | |
| val lon = -120.997498 | |
| val lat = 37.937062 | |
| val asString = dispatch.as.Response( r => {r.getHeader("Content-Type")}) | |
| val r = Await.result(Http(svc <<? Map("lon" -> s"$lon", "lat" -> s"$lat") OK asString), 3 seconds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'csv' | |
| text = File.read('/agls/data/sample.csv') | |
| file = CSV.parse(text.gsub(/\r\n?/, "\n")) | |
| rows = file.select { |r| r.length > 0 && ! r[0].starts_with?('#') && r[0].to_s.downcase != 'ranch name' } | |
| row = rows.first | |
| ranch_name, parcel_name, _, _, task_type, task_name, general_name, n, p, k, scheduled, completed, expected, actual, unit, status = row |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argonaut._, Argonaut._ | |
| import scala.util._ | |
| import scalaz._, Scalaz._ | |
| val ranch1 = """{"id":1, "parcels":[1,2,3]}""" | |
| val ranch2 = """{"id":2, "parcels":"*"}""" | |
| case class RanchShared(id: Int, parcels: Either[String, List[Int]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import akka.actor._ | |
| import akka.pattern.ask | |
| import akka.util._ | |
| import play.api.libs.iteratee._ | |
| import scala.concurrent.duration._ | |
| import scala.concurrent._ | |
| import ExecutionContext.Implicits.global | |
| val system = ActorSystem("ask-timeout") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Base { | |
| def greeting: String | |
| def from: String | |
| def greetingAgain: String = greeting + " Again" | |
| } | |
| trait Core extends Base { | |
| override def greeting = "Hello" | |
| override def from = "Patrick" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import akka.actor._ | |
| implicit val system = ActorSystem("system") | |
| class ActorStash extends Actor with Stash with ActorLogging { | |
| def receive = { | |
| case "open" => | |
| log.debug("Open received.") | |
| unstashAll() | |
| context.become({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import play.api.libs.iteratee._ | |
| import scala.concurrent._ | |
| import ExecutionContext.Implicits.global | |
| val e = Enumerator(1, 2, 3, 4, 5) | |
| val total = new Iteratee[Int, Int] { | |
| override def fold[B](folder: Step[Int, Int] => Future[B])(implicit ec: ExecutionContext): Future[B] = { | |
| folder(Step.Cont(step(0))) | |
| } |