(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 com.twitter.util.{Future => TwitterF} | |
import scala.concurrent.{Future => ScalaF, Promise => ScalaP} | |
object TwitterFutureSupport { | |
/** | |
Implicit conversion from a Twitter Future to a Scala Future | |
**/ | |
implicit def twitterFutureToScalaFuture[T](twitterF: TwitterF[T]): ScalaF[T] = { | |
val scalaP = ScalaP[T] | |
twitterF.onSuccess { r: T => |
(ns wc.core | |
(:require [clj-http.client :as client])) | |
(defn print-matchs-over [] | |
(let [data-request (client/get "http://worldcup.sfg.io/matches" {:as :json-strict}) | |
completed (filter #(= (:status %) "completed") (:body data-request))] | |
(doseq [{home-team :home_team away-team :away_team} completed] | |
(println (str (:country home-team) " " (:goals home-team) " x " | |
(:country away-team) " " (:goals away-team)))))) |
(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.
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE RecordWildCards #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
module Data.Haxl.Postgres.DataStoreExample |
{-# LANGUAGE GADTs, ConstraintKinds, FlexibleInstances, RankNTypes #-} | |
-- Our typeclass with a simple foo :: a -> String func | |
class Foo a where | |
foo :: a -> String | |
-- Our test data types and their instances of Foo | |
data MyFoo = MyFoo String | |
data MyBar = MyBar Int |
data Query = Query | |
data SomeObj = SomeObj | |
data IoOnlyObj = IoOnlyObj | |
data Err = Err | |
-- There's a decoder function that makes some object from String | |
decodeFn :: String -> Either Err SomeObj | |
decodeFn = undefined | |
-- There's a query, that runs against DB and returns array of strings |
console.log("\033[39mRunning tests…"); | |
function assertEquals(actual, expected, description) { | |
if(typeof(actual) === "undefined") { | |
console.error("\033[31m" + description + " not implemented\033[39m"); | |
} else { | |
if(actual !== expected) { | |
console.error("\033[31m" + description + " failed, expected " + expected + ", got " + actual + "\033[39m"); | |
} else { | |
console.log(description + " \033[32m ok\033[39m"); | |
} |
See comments section for more up-to-date versions of the script. The original script is from 2014 and will not work as is.
Facebook will block this feature for you while you use it, depending on how much entities you try to unfollow. It automatically unblocks in a couple of hours and you will be able to continue.
/** | |
* Created by arya on 1/2/15. | |
*/ | |
/* | |
scalaVersion := "2.11.4" | |
libraryDependencies += "com.ning" % "async-http-client" % "1.9.3" | |
libraryDependencies += "org.scalaz" %% "scalaz-concurrent" % "7.1.0" |
{-# LANGUAGE DeriveDataTypeable, GADTs, MultiParamTypeClasses, OverloadedStrings, StandaloneDeriving, TypeFamilies #-} | |
import Control.Applicative | |
import Control.Monad | |
import Data.Hashable | |
import Data.Typeable | |
import Haxl.Core | |
import Text.Printf | |
data E a where |