Skip to content

Instantly share code, notes, and snippets.

View davegurnell's full-sized avatar
🐱

Dave Pereira-Gurnell davegurnell

🐱
View GitHub Profile
@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 / 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
@davegurnell
davegurnell / placeholder.js
Created March 28, 2010 17:13
Text field placeholders with jQuery.
/* Text field placeholders
*
* Dave Gurnell, http://www.untyped.com
*
* Example usage: $("#my-date-field").placeholder("yyyy-mm-dd");
*/
(function ($) {
// -> Boolean
$.fn.hasPlaceholder = function () {
@davegurnell
davegurnell / Build.scala
Created June 13, 2012 07:50
Using the Untyped JS/Less plugins with Play 2.0 (sample SBT configuration)
import sbt._
import Keys._
import PlayProject._
import com.untyped.sbtjs.Plugin._
import com.untyped.sbtless.Plugin._
/* Example build config to use the Untyped JS/Less/Coffeescript plugins:
*
* http://github.com/untyped/sbt-plugins
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 / gist:3246361
Created August 3, 2012 09:50
Sublime Text 2 keybinding for "reveal in sidebar"
[
{ "keys": ["super+shift+r"], "command": "reveal_in_side_bar"}
]
@davegurnell
davegurnell / compiler.scala
Last active December 14, 2015 22:59
Rough idea for an update to the Untyped sbt-js and sbt-less plugins: create a single asset compiler plugin that allows flexible creation of compiler functions.
// TODO: This code doesn't distinguish between "main" files for which we want to generate outputs,
// and "library" files that are used in compilation but don't generate outputs.
case class SourceLocation(val rel: File, val relTo: File, val abs: File)
// Compilation may take several steps (Coffeescript => CommonJS => Concat => Uglifyjs etc).
// Sources are cached on disk after each step, allowing us to check timestamps to avoid
// unnecessary recompilation. Compiler steps accept one or more Sources as an argument and
// emit one or more Sources as outputs. Each Source knows where the original source file is
// located, where the target file is going to end up, and where the content is cached at the
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,