The project can be built using Lumo
npm install -g lumo-cljs
lumo build.cljs
Scenario: Repost a 3D Post | |
Given there is user A | |
And there is user B following user A | |
And there is user C following user B | |
And there is user D following user A and B | |
And user A posted a photo P1 | |
And user A posted a 3D photo P2 | |
When user B reposted P2 as P3 | |
Then the feeds should be like: | |
| feed | of | count | contains | because | |
;Print "Hi" every 2 seconds: | |
(defn t [] | |
(go (loop [] (<! (timeout 2000)) (prn "hi") (recur)))) | |
;or as a macro |
Solution without PowerMock | |
-- | |
import ch.qos.logback.classic.*; | |
import ch.qos.logback.classic.spi.LoggingEvent; | |
import ch.qos.logback.core.Appender; | |
import org.junit.*; | |
import org.junit.runner.RunWith; | |
import org.mockito.*; | |
import org.mockito.runners.MockitoJUnitRunner; |
-module(twitter_stream). | |
-author("[email protected]"). | |
%% Depends on: | |
%% ibrowse for http | |
%% couchbeam for couchbeam_json_stream (a fork of damienkatz json_stream_parse) | |
%% mochiweb for mochiweb_util:urlencode | |
-export([start/0]). |
package controllers | |
import play.api.http.{ContentTypes, ContentTypeOf} | |
import upickle.Js | |
import upickle.default._ | |
import play.api.mvc._ | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global |
In Application.scala: | |
object MyServer extends AutowirePlayServer[Api] { | |
override def routes(target: Api) = route[Api](target) | |
override def createImpl(autowireContext: AutowireContext): Api = new ServerImpl(autowireContext) | |
} | |
object Application extends Controller { | |
def api = PlayAutowire.api(MyServer)_ | |
} |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
object EitherValidationExamples { | |
type ValidationError = String | |
def validateEmail(user: User): Either[ValidationError, User] = | |
if (user.email contains "@") Right(user) else Left("Must supply a valid email") | |
def validateAge(user: User): Either[ValidationError, User] = | |
if (user.age > 18) Right(user) else Left("Must be over 18") |
(ns the-namespace.core | |
(:require [clj-http.client :as client] | |
[clojure.java.io :as io])) | |
(defn- fetch-photo! | |
"makes an HTTP request and fetches the binary object" | |
[url] | |
(let [req (client/get url {:as :byte-array :throw-exceptions false})] | |
(if (= (:status req) 200) | |
(:body req)))) |
The project can be built using Lumo
npm install -g lumo-cljs
lumo build.cljs