This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var deltaQueue = (function() { | |
| var timer = null; | |
| var q = []; | |
| var _self = {}; | |
| _self.add = function(delta) { | |
| timer && clearTimeout(timer); | |
| q.push(delta); | |
| timer = setTimeout(_self.doit, 100); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import play.api.libs.json._ | |
| object Example extends App { | |
| case class EmailPerformanceInfo(campaignCount: Int, name: Option[String]) | |
| implicit val emailPerformanceInfoWrites = new Writes[EmailPerformanceInfo] { | |
| def writes(info: EmailPerformanceInfo): JsValue = { | |
| import info._ | |
| Json.obj( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| The Oracle Java enum Planets example using the Klang DIY Enum, modified to include ordering. | |
| */ | |
| object KlangEnumPlanets extends App { | |
| trait Enum { //DIY enum type | |
| import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia | |
| type EnumVal <: Value //This is a type that needs to be found in the implementing class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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) |