(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import scala.concurrent._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.util._ | |
import java.util.concurrent.atomic.AtomicInteger | |
def firstSucceededOf[T](futures: TraversableOnce[Future[T]])(implicit executor: ExecutionContext): Future[T] = { | |
val p = Promise[T]() | |
val size = futures.size | |
val failureCount = new AtomicInteger(0) |
import sbt._ | |
import Keys._ | |
import java.net._ | |
import java.io.File | |
import play.PlayRunHook | |
/* | |
Grunt runner should be in project directory to be picked up by sbt | |
*/ | |
object Grunt { |
// optionally filter on a column with a supplied predicate | |
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) { | |
def filter[T](data: Option[T])(f: T => X => scala.slick.lifted.Column[Boolean]) = { | |
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this) | |
} | |
} | |
// example use case | |
def find(id: Option[Int], createdMin: Option[Date], createdMax: Option[Date], modifiedMin: Option[Date], modifiedMax: Option[Date]) = { |
1. Create an account at mailboxde.com and use it as package forwarder | |
2. Use a DE proxy/VPN. E.g. select one from http://www.proxynova.com/proxy-server-list/country-de/ | |
3. Create a new Google account | |
4. Use address of mailboxde.com for your Google and Wallet account | |
5. Add a credit card with the following shipping address: | |
Mailboxde.com | |
Dresdner Str. 9 | |
z. Hd. <first name> <last name>, ID <mailboxde id> | |
Zittau 02763 DE | |
+49 3583 8355148 |
import org.scalatest.BeforeAndAfterAll | |
import org.openqa.selenium.WebDriver | |
import org.openqa.selenium.htmlunit.HtmlUnitDriver | |
import org.scalatest.FlatSpec | |
import play.api.test.TestServer | |
import org.scalatest.Matchers | |
import play.api.test.Helpers | |
import org.scalatest.selenium.WebBrowser | |
import play.api.test.FakeApplication |
// Please comment in case of typos or bugs | |
import scala.slick.driver.H2Driver._ | |
val db = Database.for...(...) | |
case class Record( ... ) | |
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){ | |
... | |
def * = ... <> (Record.tupled,Record.unapply) | |
// place additional methods here which return values of type Column |
package controllers; | |
import play.mvc.Controller; | |
import play.libs.Json; | |
import static controllers.Render.*; | |
import static play.mvc.Http.MimeTypes; | |
public class Application extends Controller { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
var http = require('http'), | |
md5 = require('MD5'); | |
var options = { | |
method: 'HEAD', | |
host: 'www.gravatar.com', | |
port: 80, | |
path: '/avatar/' + md5('[email protected]') + '?d=http://bla.com' | |
}; | |
var req = http.request(options, function(res) { |
// immutable cycle | |
class Node[T]( val value: T, _next: => Node[T] ){ | |
lazy val next = _next | |
} | |
val cycle: Node[Int] = new Node( 1, new Node( 2, cycle ) ) | |
// prints List(1, 2, 1, 2, 1, 2, 1, 2, 1, 2) | |
println(cycle.iterator.take(10).map(_.value).toList) | |
implicit class NodeIterator[T](node: Node[T]){ |