Skip to content

Instantly share code, notes, and snippets.

View chrismurrph's full-sized avatar

Chris Murphy chrismurrph

View GitHub Profile
@chrismurrph
chrismurrph / views.cljs
Last active October 19, 2015 20:40
Trying to put a Reforms component into re-frame
(ns training.views
(:require [re-frame.core :as re-frame]
[re-com.core :as re-com]
[reforms.reagent :include-macros true :as f]
[training.utils :as u]))
(def h-box re-com/h-box)
(def v-box re-com/v-box)
(def box re-com/box)
(def gap re-com/gap)
@chrismurrph
chrismurrph / index.html
Created October 29, 2015 01:38 — forked from cstorey/index.html
A trivial clojurescript paint program using Reagent and core.async. Greatly inspired by the RxJS paint example.
<html>
<head>
<script src="out/goog/base.js" type="text/javascript"></script>
<script src="hello_world.js" type="text/javascript"></script>
<script type="text/javascript">goog.require("hello_world.core");</script>
</head>
<body>
</body>
<script type="text/javascript">hello_world.core.run()</script>
</html>
(ns training.component-factory
(:require-macros [re-com.core :refer [handler-fn]])
(:require [training.utils :as u]
[re-com.util :refer [deref-or-value px]]))
;;
;; A row is a {}. Each key of this {} will have a control as its value. Then also have an :id which we are going to
;; make the row number. The control when created will look like []. See my-checkbox below which is the actual control.
;;
(defn gen-table-row [create-control-fn column-keys row]
@chrismurrph
chrismurrph / gist:dccad0d583ca188255cf8b1ab046b676
Last active November 15, 2017 17:09
Dynamic generation of Fulcro Forms options
;;-> In fh ns
;;
;; Can be used in a mutation to assoc-in new options
;;
(defn input-options [[table-name id :as ident] field]
[table-name id ::f/form :elements/by-name field :input/options])
(defn input-default-value [[table-name id :as ident] field]
[table-name id ::f/form :elements/by-name field :input/default-value])
(defn options-generator [data->list-fn item->option-fn list->selected-fn]
@chrismurrph
chrismurrph / replace.clj
Last active November 22, 2017 11:29
Search and replace for going to Fulcro 2.0
(ns general.replace
(:require [clojure.string :as s]
[clojure.java.io :as io]
[clojure.pprint :as pp]))
(defn indexes-of [in-str find-str]
(loop [idx 0
indexes []]
(let [found-idx (s/index-of in-str find-str idx)]
(if found-idx
(let [st @state
desired-player-idents (->> (get st :player-year/by-id)
vals
(filter :ui/desired?)
(map :player-year-id)
(mapv (fn [id] [:player-year/by-id id])))]
(swap! state assoc-in [:desired-labels/by-id :singleton :items] desired-player-idents))
(defn identities-and-stages-hof
"The data doesn't have a player-year so we create it now. Also the games need to be
unique on their own, as they are stored in their own table.
Also the simplification of the lines for stage :improved is handled here.
The work for :nyt stage can be done always as :naive doesn't use those keys."
[desired-labels {:keys [stage]}]
(fn [idx {:keys [pname year games max] :as player-year}]
(let [player-year-id (make-player-year-id pname year)
label {:pname pname :year year}
make-simple (fn [games n]

Keybase proof

I hereby claim:

  • I am chrismurrph on github.
  • I am cjmurphy (https://keybase.io/cjmurphy) on keybase.
  • I have a public key ASAKxuvtgC_nSO_Q9zXv4JzCe2pTIMq7Ege5DQ4lczb1Wgo

To claim this, I am signing this object: