Skip to content

Instantly share code, notes, and snippets.

View davegurnell's full-sized avatar
🐱

Dave Pereira-Gurnell davegurnell

🐱
View GitHub Profile
@davegurnell
davegurnell / sparknotes.md
Created March 31, 2015 16:44
Anonymised notes from the session on Spark at Scale Summit.

Spark

Group leader:

  • Building Spark app.
  • Not in production.
  • Wants to know more about how people are building apps.
  • Currently runs jobs by hand using Spark EC2 scripts. What else is available?
@davegurnell
davegurnell / build.sbt
Last active August 29, 2015 14:18
Doodle as a dependency. Create the `build.sbt` file below and type `sbt console` to start doodling. See http://underscore.io/training/courses/creative-scala for inspiration!
scalaVersion := "2.11.2"
resolvers += "Underscore Training" at "https://dl.bintray.com/underscoreio/training"
libraryDependencies += "underscoreio" %% "doodle" % "0.1.0"
initialCommands in console := """
|import doodle.core._
|import doodle.syntax._
|import doodle.jvm._
@davegurnell
davegurnell / Highlight Scala.sublime-build
Created May 13, 2015 11:04
Syntax highlighting for Keynote slides using Sublime Text and Highlight
{
"shell_cmd": "highlight -O rtf -t 2 -K 32 -k 'PragmataPro' --syntax scala --style slides $file_path/$file_name | pbcopy"
}
@davegurnell
davegurnell / commands.sh
Created June 1, 2015 14:32
Setting up "Reveal in Sidebar" key in Sublime Text
# Switch to the "user package" directory on your hard drive:
cd 'Library/Application Support/Sublime Text 3/Packages/User/'
# Create a .sublime-keymap file containing the desired keyboard shortcut:
echo '[{ "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" }]' > 'Custom Keys.sublime-keymap'
@davegurnell
davegurnell / scaladays-shapeless-workshop-notes.md
Last active October 21, 2016 02:55
ScalaDays Shapeless Workshop Notes

Shapeless Gitter

Keep in touch and up-to-date with the latest shapeless news here:

https://gitter.im/milessabin/shapeless

Shapeless Code and Material

The shapeless codebase is on Miles' Github:

@davegurnell
davegurnell / PluginDemo.scala
Created June 17, 2015 08:48
PluginDemo.scala
trait FooPlugin {
def name: String =
// Get rid of synthetic '$'s in generated class names for singleton objects:
getClass.getSimpleName.filterNot(_ == '$')
// TODO: Insert Plugin Methods
}
object FooPlugin1 extends FooPlugin
object FooPlugin2 extends FooPlugin
case class Director(firstName: String, lastName: String, yearOfBirth: Int)
case class Film(title: String, yearOfRelease: Int, imdbRating: Double, director: Director)
val eastwood = new Director("Clint", "Eastwood", 1930)
val mcTiernan = new Director("John", "McTiernan", 1951)
val nolan = new Director("Christopher", "Nolan", 1970)
val someBody = new Director("Just", "Some Body", 1990)
val memento = new Film("Memento", 2000, 8.5, nolan)
@davegurnell
davegurnell / TypeclassDemo.scala
Created October 6, 2015 14:53
Example of the type class pattern in Scala
object TypeclasseDemo {
// The parts of the type class pattern are:
//
// 1. the "type class" itself -- a trait with a single type parameter;
//
// 2. type class "instances" for each type we care about,
// each marked with the `implicit` keyword;
//
// 3. an "interface" to the type class -- one or more methods
Introduction / Motivation
Curriculum---what you teach
- How to present Scala (OO, functional)
- Design patterns
Pedagogy---how you teach it
Technology to support teaching
Examples to motivate different students
Who Can Support It / Develop It
Why Invest in Learning Scala?
@davegurnell
davegurnell / GenericColumnType.scala
Last active April 20, 2016 15:23
Proof-of-concept automatic substitute for Slick's MappedTo, implemented using shapeless' Generic.
import shapeless._
import slick.ast.TypedType
import scala.reflect.ClassTag
trait GenericColumnTypeImplicits {
// This definition summons a column type for a type Pk provided:
// - Pk is a case class with a single field of type Underlying;
// - Slick can summon a column type for Underlying.
//
// It conflicts with MappedTo,