Skip to content

Instantly share code, notes, and snippets.

(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"]
@ioRekz
ioRekz / StackableTrait.scala
Last active December 12, 2015 12:19
Stackable Trait
//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
}
@ioRekz
ioRekz / EventNameExtractor.scala
Last active January 2, 2016 15:59
Play Scala SSE EventEtractor from json
import play.api.libs.EventSource._
implicit def pair[E]: EventNameExtractor[JsValue] = EventNameExtractor[JsValue](p => Some((p \ "event").as[String]))
(defn hello [name]
(str "Hello " name " !"))
(set!
(.-innerHTML js/klipse-container)
(str "<div>" (hello "World") "</div>"))
(require '[reagent.core :as reagent])
(def color
(reagent/atom "black"))
(def styles
{:inputs {:padding "15px"}
:inputs-label {:margin-left "5px"}
:text {:fontSize "20px"}})
(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 ""}))
(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))
(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 []
(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)))
@ioRekz
ioRekz / hiccup-dom-spec.clj
Created January 22, 2018 10:05
Specing valid hiccup dom
(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`"