Skip to content

Instantly share code, notes, and snippets.

@d6y
d6y / html
Created March 19, 2014 18:10
wtdw19embed
450x300 embed from Sports-tracker:
<iframe style='background-color: transparent;' frameborder='0' marginwidth='0' marginheight='0' scrolling='no' width='450' height='300' src='http://www.sports-tracker.com/widgets/wdgt_workout.html?username=richarddallaway&workout_key=a62erndni0j8joc2'></iframe>
@d6y
d6y / slick-reader.scala
Created August 14, 2014 07:27
Slick with Reader
import scalaz._
import Scalaz._
trait Tables {
val profile: scala.slick.driver.JdbcProfile
import profile.simple._
case class Planet(name: String, id: Long=0L)
class PlanetTable(tag: Tag) extends Table[Planet](tag, "planet") {
@d6y
d6y / json.scala
Last active August 29, 2015 14:05
Exploring everywhere
import shapeless._, poly._
object SYBMain extends App {
// Play JSON boils down to:
sealed trait JsValue
case object JsNull extends JsValue
case class JsObject (fields: Seq[(String, JsValue)]) extends JsValue
@d6y
d6y / jsnull-be-gone.scala
Created September 1, 2014 16:07
SYB from Json
import shapeless._, poly._
object SYBMain extends App {
// Play JSON boils down to:
sealed trait JsValue
case object JsNull extends JsValue
case class JsObject (fields: Seq[(String, JsValue)]) extends JsValue
@d6y
d6y / db.scala
Last active August 29, 2015 14:06
JDNI check
/**
* can we get a JDBC connection from JNDI using the default connection name?
*/
def jndiJdbcConnAvailable_? : Boolean = jndiJdbcConnAvailable_?(DefaultConnectionIdentifier)
/**
* Is the named connection available via JNDI?
* @param name the connection identifier to check.
* @return true if the JNDI name can be resolved.
*/
@d6y
d6y / streamwatch.scala
Created September 30, 2014 07:53
Stream of File Watcher
import java.io._
import java.nio.file._
import scala.collection.JavaConversions._
object WatchStream {
// Watch service can watch multiple paths (as keys) but we're just using one
// so we can ws.take and assume whatever comes back is the path we care about.
private[this] val ws = FileSystems.getDefault.newWatchService()
@d6y
d6y / vt.scala
Last active August 29, 2015 14:07
Value Types via Syntax
// We don't want to do this:
case class Contact(person: String, address: String)
// We prefer:
class Name(val value: String) extends AnyVal
class Email(val value: String) extends AnyVal
case class Contact(person: Name, address: Email)
@d6y
d6y / OSAAT1.md
Last active August 29, 2015 14:08
Pipe

Scalaz: one symbol at a time (OSAAT#1)

Symbol

|> or

Pronounced

  • Pipe
  • The Thrush combinator
@d6y
d6y / symbols
Last active August 29, 2015 14:08
scalaz symbols
scalaz (series/7.2.x)$ grep -R 'def [^A-Za-z_]' core effect concurrent iteratee
core/src/main/scala/scalaz/Arrow.scala: final def <<<[A, B, C](fbc: (B =>: C), fab: (A =>: B)): =>:[A, C] =
core/src/main/scala/scalaz/Arrow.scala: def >>>[A, B, C](fab: (A =>: B), fbc: (B =>: C)): (A =>: C) =
core/src/main/scala/scalaz/BijectionT.scala: def ***[C, D](g: Bijection[C, D])(implicit evF: F[B] =:= Id[B], evG: G[A] =:= Id[A]): Bijection[(A, C), (B, D)] =
core/src/main/scala/scalaz/BijectionT.scala: def ^^^[C, D](g: Bijection[C, D])(implicit evF: F[B] =:= Id[B], evG: G[A] =:= Id[A]): Bijection[A \/ C, B \/ D] =
core/src/main/scala/scalaz/BijectionT.scala: def <=<[C](that: BijectionT[F, G, C, A])(implicit FM: Bind[F], GM: Bind[G]): BijectionT[F, G, C, B] = compose(that)
core/src/main/scala/scalaz/BijectionT.scala: def >=>[C](that: BijectionT[F, G, B, C])(implicit M: Bind[F], GM: Bind[G]): BijectionT[F, G, A, C] = andThen(that)
core/src/main/scala/scalaz/Cofree.scala: final def =>>[B](f: Cofree[S, A] => B)(implicit
@d6y
d6y / popspec.scala
Last active August 29, 2015 14:08
populate
implicit val pc = PopulationControl(
dataSource=postgressDs,
...customzation here)
"Friends database" should {
populate("""
# User