Skip to content

Instantly share code, notes, and snippets.

@BrianLondon
BrianLondon / comments.py
Created December 13, 2019 22:10
Comments
# This is not good because it's unclear
if elapsed_seconds > 86400:
return 'expired'
# While less opaque the comment is a crutch to
# get around the unclear code
if elapsed_seconds > 86400: # seconds in a day
return 'expired'
# This is better, but still not great. It necessitates
import java.io._
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.io._
sealed trait Gen[T] {
def reader: GenReader[T]
}
sealed trait GenReader[T] {
def toGen: T

Keybase proof

I hereby claim:

  • I am brianlondon on github.
  • I am brian_london (https://keybase.io/brian_london) on keybase.
  • I have a public key ASAjyELly-bKkQQFSz8rRxx9xDFAWneymyWrwmlO4brTWwo

To claim this, I am signing this object:

// resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
// libraryDependencies += "com.github.ichoran" % "thyme_2.12" % "0.1.2-SNAPSHOT"
import ichi.bench._
import java.util.UUID
object OrderingByDemo extends App {
println(util.Properties.versionString)
// Compile time validated builder pattern using type level programming
sealed trait Fur
case object Short extends Fur
case object Long extends Fur
case object Curly extends Fur
case class Dog(name: String, age: Int, fur: Fur)
import org.apache.spark._
object PartitionTest extends App {
class MyParitioner() extends Partitioner {
override def numPartitions = 3
override def getPartition(x: Any) = x match { case n: Int => n % 3 }
override def toString = s"MyPartitioner"
}
// Returns Some((user_id, email_content)) if an email should be
// triggered None otherwise
def eventTriggeredEmail(userId: Int, eventDescription: String):
Option[(Int, String)] = ???
object Emailer extends App with MyConfigurationMixin {
val sparkConf = new SparkConf()
.setAppName("Emailer")
.setMaster("local[4]")
val ssc = new StreamingContext(sparkConf, Seconds(1))