Skip to content

Instantly share code, notes, and snippets.

View selfsame's full-sized avatar

Joseph Parker selfsame

  • Clover Food Lab
View GitHub Profile
@selfsame
selfsame / gist:9030568
Created February 16, 2014 07:26
interface sets are passed to specific view components, still get state bleed for all view windows.
(sug/defcomp report
[data owner]
{:render-state
(fn [_ state]
(dom/li nil (prn-str (rand-int 100) data) ))})
(sug/defcomp window
@selfsame
selfsame / gist:9030937
Created February 16, 2014 08:02
Using multiple roots on the same data will still share state bleeding at cursor path similarity
(sug/defcomp window
[data owner]
{:render-state
(fn [_ state]
(let [[x y w h] (:xywh state)]
(dom/div #js {:ref "tool" :style #js {:left x :top y :width w :height h :position "absolute" :border "1px solid red"}}
(sug/make draggable data {:opts {:className (str "title")
:content (str (:view state) (rand-int 100))}
@selfsame
selfsame / gist:9031240
Last active August 29, 2015 13:56
root component tracks UI state, and builds UI components with a drilled cursor (dummy wrapper for app data), UI changes are handled by root, which compares state and render state for individual components to see if they need :state passed for positioning. Draggable component is using dummy data to get unique cursor path, otherwise it triggers st…
;sug/private is an atomic data store that links the owner path+:react-key to a data map.
;it works much like state, but it doesn't trigger any renders and doesn't have pending/rendered versions
;it's very helpful here to stash the mouse drag meta info without triggering app updates.
(defn unbind-drag [owner]
(let [[mouse-up mouse-move] (sug/private owner :event-handlers)]
(.unbind (js/$ js/window) "mouseup" mouse-up)
(.unbind (js/$ js/window) "mousemove" mouse-move)))
(defn drag-stop [e data owner]
(defn collapse-node [start]
(loop [data start result []]
(let [d (if (sequential? data) data [data])
sorted (map (fn [v]
{:id (:uid v) :babies (:children v)}) d)
uids (flatten (filter #(not (nil? %)) (map :id sorted)))
babies (vec (flatten (filter #(not (nil? %)) (map :babies sorted))))]
(if-not (pos? (count babies))
(concat result uids)
if window.DEBUG
console.log "running outliner.js"
# Outliner should be a window.tools object, should easily match up with selection
$(window.ifrm).ready ->
window.tools['outliner'] =
toolbox: 0
moving: 0
move_start: [0,0]
<?php
$con = new Connection();
$res = $con->query('SELECT word, hash FROM `keywords` LIMIT 0, 30 ');
$rows = array();
while($r = $res->fetch_assoc()) {
echo $r["word"]." ".$r["hash"]."<br>";
}
"The space captain" by Joseph Parker
Chapter 1 - Declarations
A zone is a kind of container. Zones are usually enterable. Zones are usually transparent.
A galaxy is a kind of room.
A cluster is a kind of zone.
A system is a kind of zone.
(sug/defcomp t-c-2
[data owner opts]
{:render-state
(fn [_ state]
(let []
(.log js/console (.-_rootNodeID owner))
(dom/div nil
(dom/p nil (prn-str (.-__om_cursor (.-props owner))))
(dom/button #js {:onClick #(sug/up! :c owner {:thing true})} "eventer")
)))})
@selfsame
selfsame / gist:f39f7e6d066ccdb64d5a
Created July 15, 2014 05:45
filtering om cursors test
(def app-state (atom {:vect
[{:uid 0 :i 0}
{:uid 1 :i 0}
{:uid 2 :i 0}
{:uid 3 :i 0}
{:uid 4 :i 0}
{:uid 5 :i 0}
{:uid 3 :i 0}]}))
(plomb/defcomp item [data owner]
;saved documents have data for :filesystem, :filepath, :unsaved-changes, :file-uid
(defn get-iframe [data]
"Returns the iframe element for the given
Workspace cursor"
(let [id (:iframe-id data)]
(.getElementById js/document id)))
(defn to-html [element]
"Returns the HTML string of the element and it's contents, when given an iframe returns only content HTML.")