Skip to content

Instantly share code, notes, and snippets.

@aholland
aholland / gist:0845bf29d836d672d006ab58f5f1c73c
Last active March 23, 2017 09:40
Some Slick/ Shapeless code that nearly works.
//This method works but it is verbose and is specific to the firstNames column
def updatePD_FirstNames(id: ids.PersonalDetailsId, firstNames: StringLtd30): Future[Int] = {
val q1: Query[tables.PersonalDetails, PersonalDetailsRow, Seq] = for {
row: tables.PersonalDetails <- tables.PersonalDetails if row.id === id
} yield {
row
}
//This mapper can instead be put into the parameter list. That works and is what I have done in updatePD_SL, on line 19 below.
val mapper: tables.PersonalDetails => tables.profile.api.Rep[StringLtd30] = (pdTable: tables.PersonalDetails) => {
val r: tables.profile.api.Rep[StringLtd30] = pdTable.firstNames
@aholland
aholland / gist:c9c2112b5aa40dcfc55fc91dc7f0b240
Last active June 15, 2017 15:33
Long-winded because not able to refer to type in super-class type parameter list.
class Editor[T](initialValue: T)
class A[F, E <: Editor[F]](fieldMaker: () => F, edMaker: F => E) {
val field: F = fieldMaker()
val editor: E = edMaker(field)
}
locally { //Long
class B(opStringTypeMaker: () => (Option[String]))
extends A[Option[String], Editor[Option[String]]](opStringTypeMaker, opS => new Editor(opS)) {
}
val b = new B(() => Some("First"))
@aholland
aholland / ResizeSensor.js
Created February 16, 2017 21:33
Marc Schmidt's ResizeSensor.js
/**
* Copyright Marc J. Schmidt. See the LICENSE file at the top-level
* directory of this distribution and at
* https://github.com/marcj/css-element-queries/blob/master/LICENSE.
*/
;
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(factory);
} else if (typeof exports === "object") {
@aholland
aholland / Play ClassNotFound Trouble
Created March 9, 2016 22:39
The full output from Play showing error "Caused by: java.lang.ClassNotFoundException: scala.reflect.internal.AnnotationInfos$ErroneousAnnotation$"
C:\Workspace\IdeaProjects\prescalajs>sbt run
[info] Loading project definition from C:\Workspace\IdeaProjects\prescalajs\project
[info] Set current project to vintur (in build file:/C:/Workspace/IdeaProjects/prescalajs/)
[info] Updating {file:/C:/Workspace/IdeaProjects/prescalajs/}vintur...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
--- (Running the application, auto-reloading is enabled) ---
[info] p.a.l.c.ActorSystemProvider - Starting application default Akka system: application