Skip to content

Instantly share code, notes, and snippets.

View quintona's full-sized avatar

Quinton Anderson quintona

  • Sydney Australia
View GitHub Profile
@quintona
quintona / build.sbt
Created May 8, 2014 11:29
Native RPM SBT example
import com.typesafe.sbt.packager.Keys._
import sbt.Keys._
import com.typesafe.sbt.SbtNativePackager._
name := "hw"
version := "1.0"
scalaVersion := "2.10.3"
@quintona
quintona / Macros.scala
Created March 25, 2014 22:28
Trait expansion macro
object helloMacro {
def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
import c.universe._
import Flag._
val result = {
annottees.map(_.tree).toList match {
case q"trait $name extends ..$parents { ..$body }" :: Nil =>
q"""
trait $name extends ..$parents {
def hello = "hello"
@quintona
quintona / build.scala
Created March 21, 2014 05:54
SBT Build plugin for Hadoop legacy jar format
object build extends Build {
val maestroJar = TaskKey[File]("maestro-jar", "Creates a packaged jar that works for maestro")
def allFiles(base: File): Seq[File] = {
val finder: PathFinder = PathFinder(base).***
finder.get
}
val maestroJarSettings: Seq[Project.Setting[_]] = inTask(maestroJar)(Seq(
artifactPath <<= artifactPathSetting(artifact),
@quintona
quintona / SomeMain.scala
Created March 20, 2014 12:20
Simpler Tool for scalding that doesn't use reflection
object OpsMain {
def main(args : Array[String]) {
hadoop.util.ToolRunner.run(new hadoop.mapred.JobConf, new Tool[XXX]({args => new XXX(args)}), args)
}
}
@quintona
quintona / build.scala
Created March 19, 2014 22:20
Very nice little hack that Laurence put together to change the way one can package dependencies with assembly. This is potential useful for only hadoop based deployments
val IncludeInLib = Configurations.config("include-lib")
def addSpecifiedDependenciesToLibInAssembly = inConfig(IncludeInLib)(Defaults.configSettings) ++ Seq(
(libraryDependencies in IncludeInLib) := Nil, // needed otherwise scala library gets included.
(assembledMappings in assembly) <<= (libraryDependencies in IncludeInLib, externalDependencyClasspath in IncludeInLib, assembledMappings in assembly) map ((specified, managed, mappings) => {
@quintona
quintona / Build.scala
Created March 3, 2014 11:39
Build.scala
import sbt._
import Keys._
import sbtassembly.Plugin._, AssemblyKeys._
object build extends Build {
type Sett = Project.Setting[_]
lazy val standardSettings: Seq[Sett] =
Defaults.defaultSettings ++ Seq[Sett](
@quintona
quintona / gist:8879309
Created February 8, 2014 09:10
The work around to get qibuild working on my Mac
There is a pathing issue with qiBuild. when I run qibuild configure I always get the following error:
Current build worktree: xxxx
Using toolchain: mytoolchain
Build type: Debug
[ERROR]: Could not find qibuild cmake framework path
Please file a bug report with the details of your installation
When I run the command in debug mode I see some paths that don't match my system:
Build type: Debug
@quintona
quintona / gist:7670373
Created November 27, 2013 03:42
Simple example calculating the gini in R
calc.gini <- function(y)
{
num.pos <- sum(y==1)
num.neg <- sum(y==0)
tpr <- cumsum(y==1)/num.pos
fpr <- cumsum(y==0)/num.neg
area <- (tpr[-1] + tpr[1:(length(tpr)-1)]) %*% (fpr[-1] - fpr[1:(length(fpr)-1)])
1 - as.numeric(area)
}
@quintona
quintona / Aggregate Composition
Created November 25, 2013 10:37
Implementation of the aggregation test from first principles using a basic Monoid
trait M[A] {
def op( a1: A, a2: A): A
def zero: A
}
val sumIntMonoid = new M[Int]{
val zero = 0
def op(a1:Int, a2:Int) = a1 + a2
}
@quintona
quintona / Instructions
Last active December 19, 2015 01:29
Follow the instructions to add NAT functionality to the OpenVPN for AWS VPC
In order to
* paste the text from the file in the gist: sudo vim /usr/local/sbin/configure-pat.sh
* Make it executable: sudo chmod u+x /usr/local/sbin/configure-pat.sh
* Edit /etc/rc.local: "sudo vim /etc/rc.local" and add the following line: "/usr/local/sbin/configure-pat.sh"
* Reboot the instance