Skip to content

Instantly share code, notes, and snippets.

// 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
}
// 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").
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
(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)
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]
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)
// 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:
trait MapSeqZip[A,B] { self =>
def focus :(A,B)
def back :Map[A,Seq[B]]
def forward :Map[A,Seq[B]]
lazy val index = back.map(_._2.size).sum + back.size - 1
lazy val underlying :Map[A,Seq[B]] = back.get(focus._1) match {
case Some( seq ) =>
package com.ticketfly.pillage
import spock.lang.*
class PillagedReporterSpec extends Specification {
@Shared String addy
@Shared String name
@Shared PillagedReporter reporter
@Shared def port = 6666
package com.ticketfly.pillage;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
import java.nio.channels.SocketChannel;
import java.util.Map;