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
| // In cases where we have an AJAX request for IE with an uploaded file, we | |
| // assume we served through an iframe (a fairly safe assumption) and serve | |
| // up the response with a content type of text/plain so that IE does not | |
| // attempt to save the file. | |
| LiftRules.responseTransformers.append { | |
| resp => | |
| (for (req <- S.request) yield { | |
| resp match { | |
| case InMemoryResponse(data, headers, cookies, code) | |
| if ! req.uploadedFiles.isEmpty && |
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
| /** | |
| * Part Zero : 10:15 Saturday Night | |
| * | |
| * (In which we will see how to let the type system help you handle failure)... | |
| * | |
| * First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0) | |
| */ | |
| import scalaz._ | |
| import Scalaz._ |
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
| 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 | |
| private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values | |
| //Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal | |
| private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS} | |
| val oldVec = get |
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 org.specs2._ | |
| import specification._ | |
| import matcher._ | |
| import lib.{OptionFormatter => OF} | |
| import net.liftweb.common.Logger | |
| import net.liftweb.mapper.Like | |
| import model._ |
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.net._ | |
| import java.util.UUID | |
| import com.twitter.conversions.time._ | |
| import com.twitter.finagle.builder.ClientBuilder | |
| import com.twitter.util._ | |
| import java.nio.charset.Charset | |
| import org.jboss.netty.buffer.{ChannelBuffers, ChannelBuffer} | |
| import org.jboss.netty.handler.codec.http._ | |
| import com.twitter.finagle.stream.Stream |
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
| // Modified SpamLord.java to call clojure code | |
| public List<Contact> processFile(String fileName, BufferedReader input) { | |
| List<Contact> contacts = new ArrayList<Contact>(); | |
| // for each line | |
| Matcher m; | |
| String email; | |
| try { | |
| List results = new spamlord().process(input); |
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
| trait Bind[M[_]] { | |
| def fmap[A, B](ma: M[A], f: A => B): M[B] | |
| def bind[A, B](ma: M[A], f: A => M[B]): M[B] | |
| } | |
| trait Monad[M[_]] extends Bind[M]{ | |
| def unit[A](a: => A): M[A] |
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
| package code.mockweb | |
| /* | |
| * Copyright 2011 WorldWide Conferencing, LLC | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * |
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
| package bootstrap.liftweb { | |
| import net.liftweb.common._ | |
| import net.liftweb.http._ | |
| import js._ | |
| import LiftRules._ | |
| import net.liftweb.util.Helpers._ | |
| /** | |
| * Provides automatic reloading of the client on session loss. | |
| * |
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
| case class Config(host: String, port: Int) { | |
| def prettyPrint(prefix: String, msg: String): String = | |
| List(prefix, ": ", msg, " on ", host, ":", port.toString).mkString | |
| } | |
| /** | |
| * Passing a configuration with implicits is like | |
| * working in the state monad. You can "put" a | |
| * new configuration even though we don't want that | |
| * to happen in this particular example. We don't |
OlderNewer