This file contains 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
// An ADT+shapeless as a drop-in replacement for a standard Scala Enumeration. | |
// | |
// First the unsafe standard Scala Enumeration ... | |
// | |
object ScalaEnumDemo extends App { | |
// Example from scala.Enumeration scaladoc. Terse ... | |
object WeekDay extends Enumeration { | |
type WeekDay = Value | |
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value | |
} |
This file contains 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
// Creating a generic recursive data structure with autoclosure. (READ ALL NOTES; THIS MAY NOT DO WHAT YOU WANT.) | |
// Closures are reference types, so the size is known (? I think ?) | |
// Note that this is just because of unimplemented features in the compiler in Beta5 | |
// There's no reason to think this is a long-term requirement. | |
// IMPORTANT: the closure will run every time you access this value, so if that has | |
// side effects, this won't work. It's only possible on pure value types. | |
// But the fact that this works as expected is actually kind of incredible. | |
// Think about what is required for it to work out the type for NestedList.Elem("first"). |
This file contains 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
process, absent anything else, is strictly pull | |
you should think of run like a giant wheel that is spinning and pulling in some rope, which is the process | |
the other end of that rope MAY be attached to a queue | |
you're pulling from that queue | |
and there may be an observer sitting on the rope which pushes into another queue |
This file contains 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
(global-set-key (kbd "M-?") 'flash-active-buffer) | |
(make-face 'flash-active-buffer-face) | |
(set-face-attribute 'flash-active-buffer-face nil | |
:background "red" | |
:foreground "black") | |
(defun flash-active-buffer () | |
(interactive) | |
(run-at-time "100 millisec" nil | |
(lambda (remap-cookie) |
This file contains 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
trait UnapplyMT[TC[_[_[_], _]], N[_], MTNA] { | |
/** the type constructor */ | |
type MT[_[_], _] | |
/** The type that MT is applied to */ | |
type A | |
/** The instance of the type class */ | |
def TC: TC[MT] |
This file contains 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._ | |
/** | |
* Use the state monad to 'process a trade' and store the new trade. | |
* As well as processing the trade, handle validation errors. | |
*/ | |
object StateMonad extends App { | |
case class Trade(info: String) |
This file contains 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
// Generated on 2013-07-30 using generator-webapp 0.2.6 | |
'use strict'; | |
var LIVERELOAD_PORT = 35729; | |
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT}); | |
var mountFolder = function (connect, dir) { | |
return connect.static(require('path').resolve(dir)); | |
}; | |
// # Globbing | |
// for performance reasons we're only matching one level down: |
This file contains 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
# to install the latest stable version: | |
brew install play | |
# to install play-2.1-RC3: | |
# if you already have a version of play installed you will need to unlink it. | |
brew unlink play | |
brew install https://raw.github.com/gist/4675514/play.rb | |
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands): | |
brew switch play 2.0.4 |
This file contains 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 com.twitter.finagle.http.path._ | |
import com.twitter.finagle.http.service.RoutingService | |
import com.twitter.finagle.http.{Request, Response, RichHttp, Http} | |
import com.twitter.finagle.{Service, SimpleFilter} | |
import org.jboss.netty.handler.codec.http._ | |
import org.jboss.netty.handler.codec.http.HttpResponseStatus._ | |
import org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1 | |
import org.jboss.netty.buffer.ChannelBuffers.copiedBuffer | |
import org.jboss.netty.util.CharsetUtil.UTF_8 | |
import com.twitter.util.Future |
This file contains 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 sbt._ | |
import sbt.Keys._ | |
object build extends Build { | |
lazy val generate = Project( | |
id = "source-gen", | |
base = file("."), | |
settings = Defaults.defaultSettings ++ generateSourceSettings | |
) | |
NewerOlder