Skip to content

Instantly share code, notes, and snippets.

🦊
Crazy like a fox

Matt Hicks darkfrog26

🦊
Crazy like a fox
Block or report user

Report or block darkfrog26

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View aoc2018.day1.scala
package com.matthicks.aoc2018
import scala.annotation.tailrec
import scala.io.Source
object Day1 {
private lazy val data: List[Int] = {
Source.fromURL(getClass.getClassLoader.getResource("day1.txt")).getLines().toList.map(_.toInt)
}
View test.scala
sealed trait MyOption[+A] extends Any {
def isEmpty: Boolean
def isDefined: Boolean
}
class MySome[+A](val value: A) extends AnyVal with MyOption[A] {
def isEmpty: Boolean = false
def isDefined: Boolean = true
}
@darkfrog26
darkfrog26 / RegressionApp.scala
Last active Sep 11, 2018 — forked from otobrglez/RegressionApp.scala
Linear regression with pure Scala
View RegressionApp.scala
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
// based on the original work: https://gist.github.com/otobrglez/08e9064209c9fc777ea5/d8000c300d2fd72db5a3445b8a93612680acaabb
// For kicks, I cleaned this up
object Regression {
def linear(pairs: Seq[Data]): Future[Regression] = for {
x1 <- Future(pairs.foldLeft(0.0)((sum, d) => sum + d.x))
y1 <- Future(pairs.foldLeft(0.0)((sum, d) => sum + d.y))
View scribe-2018.08.27.benchmarks.json
[
{
"jmhVersion" : "1.20",
"benchmark" : "scribe.benchmark.LoggingSpeedBenchmark.withLog4j",
"mode" : "avgt",
"threads" : 1,
"forks" : 10,
"jvm" : "/usr/lib/jvm/java-8-oracle/jre/bin/java",
"jvmArgs" : [
],
View ugly-parse.scala
private val groupCharacters = Set('(', '[', '{', '"')
private val groupEndings = Map('(' -> ')', '[' -> ']', '{' -> '}', '"' -> '"')
private def parseWords(s: String): List[String] = {
val b = new StringBuilder
var open = List.empty[Char]
val words = ListBuffer.empty[String]
s.foreach {
case ' ' if open.isEmpty => {
if (b.nonEmpty) {
words += b.toString()
View benchmark.json
This file has been truncated, but you can view the full file.
[
{
"jmhVersion" : "1.20",
"benchmark" : "scribe.benchmark.LoggingSpeedBenchmark.withLog4j",
"mode" : "thrpt",
"threads" : 1,
"forks" : 10,
"jvm" : "/usr/lib/jvm/java-8-oracle/jre/bin/java",
"jvmArgs" : [
View BugTest.scala
package example
import scala.annotation.compileTimeOnly
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
class BugTest {
def example(message: => String): LogRecord = macro BugTest.example
}
View output.txt
[error] java.lang.NoClassDefFoundError: org/scalacheck/Test$TestCallback
[error] at java.lang.Class.getDeclaredFields0(Native Method)
[error] at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
[error] at java.lang.Class.getDeclaredFields(Class.java:1916)
[error] at scala.reflect.runtime.JavaMirrors$JavaMirror$FromJavaClassCompleter.$anonfun$completeRest$4(JavaMirrors.scala:787)
[error] at scala.reflect.runtime.JavaMirrors$JavaMirror$FromJavaClassCompleter.$anonfun$completeRest$1(JavaMirrors.scala:797)
[error] at scala.reflect.runtime.JavaMirrors$JavaMirror$FromJavaClassCompleter.completeRest(JavaMirrors.scala:755)
[error] at scala.reflect.runtime.JavaMirrors$JavaMirror$FromJavaClassCompleter.complete(JavaMirrors.scala:751)
[error] at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1532)
[error] at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$9.scala$reflect$runtime$SynchronizedSymbols$SynchronizedS
View gist:4d87d50ecc608801173bd259016bad2d
[
{
"jmhVersion" : "1.20",
"benchmark" : "scribe.benchmark.LoggingSpeedBenchmark.withLog4j",
"mode" : "avgt",
"threads" : 1,
"forks" : 10,
"jvm" : "/usr/lib/jvm/java-8-oracle/jre/bin/java",
"jvmArgs" : [
],
@darkfrog26
darkfrog26 / GaussianClustering.scala
Created Jan 16, 2018
Gaussian Clustering with Spark ML
View GaussianClustering.scala
package partners.campaign.lemur.recommendations
import org.apache.spark.ml.clustering.GaussianMixture
import org.apache.spark.ml.linalg.{Vector, Vectors}
import org.apache.spark.sql.Row
import partners.campaign.lemur.recommendations.ClusteringExample.spark
object GaussianClustering extends SparkExample {
override def run(): Unit = {
// Loads data
You can’t perform that action at this time.