The project can be built using Lumo
npm install -g lumo-cljs
lumo build.cljs
| /** | |
| * @typedef MutationCallback | |
| * @param {NodeList} addedNodes A NodeList of elements that have been added to the DOM. | |
| * @param {NodeList} removedNodes A NodeList of elements that have been removed from the DOM. | |
| */ | |
| /** | |
| * Add a MutationObserver to a DOM node. | |
| * | |
| * @example | |
| * |
The project can be built using Lumo
npm install -g lumo-cljs
lumo build.cljs
| (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)))) |
| 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") |
| 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" |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <form> | |
| <!-- in firefox you can't choose a file diretory --> | |
| <input type="file" id="file_input" directory webkitdirectory multiple /> |
| 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)_ | |
| } |
| 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 |
| -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]). |
| 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; |