Skip to content

Instantly share code, notes, and snippets.

View metasim's full-sized avatar
🎹

Simeon H.K. Fitch metasim

🎹
View GitHub Profile
/*
* Copyright 2017 Astraea, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
This file has been truncated, but you can view the full file.
{
"paragraphs": [
{
"title": "Boilerplate Setup",
"text": "// Java Imports\nimport java.sql.Timestamp\n\n// Spark Imports\nimport org.apache.spark.sql.gt._\nimport org.apache.spark.sql.gt.functions._\nimport org.apache.spark.ml._\nimport org.apache.spark.ml.classification._\nimport org.apache.spark.ml.evaluation._\nimport org.apache.spark.ml.feature._\nimport org.apache.spark.ml.tuning._\nimport org.apache.hadoop.fs.Path\n\n// GeoTrellis Imports\nimport geotrellis.raster._\nimport geotrellis.spark._\nimport geotrellis.util.Filesystem\nimport geotrellis.vector.io._\nimport geotrellis.vector._\nimport geotrellis.raster.histogram.Histogram\n\n// Astraea Imports\nimport astraea.model._\nimport astraea.spark.util._\nimport astraea.zeppelin._\nimport astraea.spark.ingest.AstraeaSparkContextMethods._\n\ngtRegister(sqlContext)",
"user": "anonymous",
"dateUpdated": "May 25, 2017 5:45:31 PM",
"config": {
"colWidth": 12.0,
"enabled": true,
package org.apache.spark.sql.gt
import ...
class TileUDT extends UserDefinedType[Tile] {
override val typeName = "st_tile"
override def userClass = classOf[Tile]
import geotrellis.raster.{ByteConstantTile, MultibandTile}
import geotrellis.spark.io.avro.AvroRecordCodec
import geotrellis.spark.io.avro.codecs.Implicits._
def codecOf[T: AvroRecordCodec](t: T) = implicitly[AvroRecordCodec[T]]
val tile = MultibandTile(
ByteConstantTile(1, 10, 10),
ByteConstantTile(2, 10, 10),
import pprint.PPrinter._
/**
* Pretty printer support for products where field names are rendered.
* @author sfitch
* @since 9/14/16
*/
object ProductPPrinter {
/** Pretty Printer adding 'key = value' field rendering. */
implicit def ProductWithFieldsPPrinter[P <: Product] = new pprint.PPrinter[P] {
import java.io.DataOutputStream
import geotrellis.raster.io.geotiff.GeoTiffData
import geotrellis.raster.io.geotiff.tags.codes.TagCodes.PhotometricInterpTag
import geotrellis.raster.io.geotiff.tags.codes.TiffFieldType.ShortsFieldType
import geotrellis.raster.io.geotiff.writer.{GeoTiffWriter, TiffTagFieldValue}
/**
* Overridden GeoTiff writer to add photometric interpretation tags
*/
package <empty> {
case class Person extends AnyRef with Product with Serializable {
<caseaccessor> <paramaccessor> private[this] val name: String = _;
<stable> <caseaccessor> <accessor> <paramaccessor> def name: String = Person.this.name;
<caseaccessor> <paramaccessor> private[this] val age: Int = _;
<stable> <caseaccessor> <accessor> <paramaccessor> def age: Int = Person.this.age;
def <init>(name: String, age: Int): Person = {
Person.super.<init>();
()
};
import scala.reflect.runtime.universe._
sealed trait not[-A] {}
type union[A,B] = {
type prove[Z] = not[not[Z]] <:< not[not[A] with not[B]]
}
type Tagged[U] = { type Tag = U }
type @@[T, U] = T with Tagged[U]
case class Transformed(state: Boolean, value: String)
trait ADomain
trait BDomain
@metasim
metasim / micropublish.sbt
Created March 22, 2016 13:19
M2 publish to a directory in SBT
// Keys to have a submodule publish to a micro-repo.
val publishMicroRepo = taskKey[Unit]("Task to publish artifacts to a local brooklyn micro-repo")
val microRepoTargetDir = settingKey[File]("Directory where to save repository")
val microRepoPublishConfiguration = taskKey[sbt.PublishConfiguration]("Micro-repo publish task config")
val microRepoName = settingKey[String]("Unique sbt repository ID")
// ----------------------------------------------------------------------------
// Support for publishing core libraries to project micro-repo
// ----------------------------------------------------------------------------
lazy val publishSettings = Seq(
@metasim
metasim / gremlinUnion.scala
Last active January 25, 2016 16:27
Example of using `union` combinator in gremlin-scala.
val g = TinkerFactory.createModern().asScala
val Age = Key[Vertex]("age")
val Lang = Key[Vertex]("lang")
val trav = g.V(4)
.union(
GremlinScala(__[Vertex]).in().value(Age),
GremlinScala(__[Vertex]).out().value(Lang)