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
(ns hiccup-html-spec.core | |
(:require [clojure.spec.alpha :as s] | |
[phrase.alpha :refer [defphraser phrase-first phrase]])) | |
;;GOALS | |
;;- spec a valid dom hiccup | |
;;- have errors like React for | |
;; . invalid descendant -> "<div> cannot appear as a descendant of <p>" | |
;; . unknown tag -> "The tag <divv> is unrecognized in this browser" | |
;; . void element -> "img is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`" |
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
(require | |
'[cemerick.url :as url] | |
'[clojure.spec.alpha :as s] | |
'[clojure.spec.gen.alpha :as sgen]) | |
(defn non-empty-string-alphanumeric | |
[] | |
(sgen/such-that #(not= "" %) | |
(sgen/string-alphanumeric))) |
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
(require '[reagent.core :as reagent]) | |
(require '[cljs.core.async :as async :refer [<! >!]]) | |
(require-macros '[cljs.core.async.macros :refer [go go-loop]]) | |
(def state | |
(reagent/atom | |
{:todos [{:text "Learn Clojure" :done true} | |
{:text "Try Clojurescript" :done true} | |
{:text "Make an App"}] | |
:todo-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
(require '[reagent.core :as reagent]) | |
(require '[cljs.core.async :as async :refer [<! >!]]) | |
(require-macros '[cljs.core.async.macros :refer [go go-loop]]) | |
(def increment-chan (async/chan)) | |
(def counter | |
(reagent/atom 1)) | |
(defn increment [] |
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
(require '[reagent.core :as reagent]) | |
(require '[goog.object :as gobject]) | |
(def socket (js/WebSocket. "wss://echo.websocket.org")) | |
(gobject/set socket "onopen" #(prn "Socket Open")) | |
(gobject/set socket "onmessage" #(prn "New Message Received" (.-data %))) | |
(defn send-message [msg] | |
(.send socket msg)) |
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
(require '[reagent.core :as reagent]) | |
(def color | |
(reagent/atom "black")) | |
(def styles | |
{:inputs {:padding "15px"} | |
:inputs-label {:margin-left "5px"} | |
:text {:fontSize "20px"}}) |
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
(defn hello [name] | |
(str "Hello " name " !")) | |
(set! | |
(.-innerHTML js/klipse-container) | |
(str "<div>" (hello "World") "</div>")) |
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
(defproject clr "0.1.0-SNAPSHOT" | |
:description "FIXME: write this!" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.7.0"] | |
[org.clojure/clojurescript "1.7.145"] | |
[org.clojure/core.async "0.2.371"] | |
[cljs-http "0.1.37"] |
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 play.api.libs.EventSource._ | |
implicit def pair[E]: EventNameExtractor[JsValue] = EventNameExtractor[JsValue](p => Some((p \ "event").as[String])) |
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
//every power got specific points | |
trait Power { | |
def points: Int | |
} | |
trait Speed extends Power { | |
//abstract override is the special identifier for stackable feature | |
//super is now referencing the previous trait in the linearization that is, the previous in the declaration | |
abstract override def points = super.points + 10 | |
} |