Skip to content

Instantly share code, notes, and snippets.

View atroche's full-sized avatar

Alistair Roche atroche

View GitHub Profile
(ns faceviz.reagent-video
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [reagent.core :as r]
[cljs.core.async :as async]))
(def TIME-REFRESH-INTERVAL-MS
33)
;; note: there is an event fired on the video element called
;; timeupdate, but it can be as slow as 4Hz, which is just
(ns faceviz.reagent-video-test
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [clojure.test :as test :refer [deftest is]]
[clojure.core.async :as async]
[faceviz.reagent-video :as r-video]
[reagent.core :as r]))
(deftest mounted-player-sanity-check
(let [root-node (.createElement js/document "div")
player-state* (r/atom {:current-time 0})]
(ns faceviz.views
(:require [goog.string :as gstring]
[goog.string.format]
[reagent.core :as r]
[faceviz.reagent-video :as rv]))
(def sample-video-url
"https://ia800502.us.archive.org/10/items/WebmVp8Vorbis/webmvp8.webm")
~/t/fsof   circleci $…  circleci build 2267ms  Wed 01 Nov 2017 12:10:39 PM MDT
====>> Spin up Environment
Build-agent version 0.0.4499-d8fe89b (2017-10-31T13:39:51+0000)
Starting container circleci/clojure:lein-2.7.1
using image circleci/clojure@sha256:7f4647ec1f1dc1078fa5904c48d3c37106ba4b266b7f386da38c477a4bae6213
Using build environment variables:
BASH_ENV=/tmp/.bash_env-localbuild-1509559843
IMG="fsof-lein-test"
REPL_PORT=6666
docker build \
-t $IMG \
-f Dockerfile.dev \
--build-arg USERID=$(id -u) \
--build-arg GROUPID=$(id -u) \
--build-arg USERNAME=$USER \
.
(require '[think.parallel.core :as par])
(let [new-val (inc counter)]
(alter-var-root #'counter (constantly 100))
(let [vals (binding [counter 50]
(par/queued-pmap 50 (fn [_] counter) (range 200)))]
(alter-var-root #'counter (constantly 400))
(println vals)))
(println counter)
(defn fake-poll-fn []
(range 10))
(defn possible-not-claimed?
[work-item]
(pos-int? work-item))
(defn claim-log-process-transact
[work-item]
I walked by the sea, and there came to me,
as a star-beam on the wet sand,
a white shell like a sea-bell;
trembling it lay in my wet hand.
In my fingers shaken I heard waken
(ns scratch.core
(:require
[reagent.core :as r]
[taoensso.tufte :as tufte :refer (defnp p profiled profile)]))
(enable-console-print!)
(tufte/add-basic-println-handler! {})
(defonce props (r/atom {:todos 1}))
@atroche
atroche / reagent_strict_mode.cljs
Created April 28, 2018 06:47
An example of enabling React's new "Strict Mode" in reagent
;; use [reagent "0.8.0"]
(let [unsafe-component (r/create-class
{:reagent-render (fn [& args]
(js/console.log "this should be printed twice, because strict mode 'double invokes' render methods in dev mode, to bring side effectful code to the fore")
[:div
"rendering this should produce a warning in the console about lifecycle methods in "
[:a {:href "https://reactjs.org/docs/strict-mode.html"}
"strict mode"]])
:component-will-mount (fn [this]