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 cljsplayground.core | |
| (:require [reagent.core :as reagent :refer [atom]] | |
| [goog.dom :as dom] | |
| [goog.events :as events] | |
| [cljs.tools.reader :as r] | |
| [cljs.analyzer :as ana] | |
| [cljs.compiler :as c] | |
| [cljs.core.async :refer [put! chan <! >! timeout close!]] | |
| [cljsplayground.console :as console]) | |
| (:require-macros [cljs.core.async.macros :refer [go go-loop]])) |
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 cljsplayground.core | |
| (:require [reagent.core :as reagent :refer [atom]] | |
| [cljs.core.async :refer [put! chan <! >! timeout close!]]) | |
| (:require-macros [cljs.core.async.macros :refer [go go-loop]])) | |
| ;; jquery and jqconsole are included into index.html with <script> tag for this example | |
| (defn jqconsole-prompt [jqconsole chan] | |
| (.Prompt jqconsole true #(put! chan %) (fn [str] (.log js/console str) false))) |
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
| function JQConsole(outer_container, header, prompt_label, prompt_continue_label) {}; | |
| JQConsole.prototype.ResetHistory = function() {}; | |
| JQConsole.prototype.ResetShortcuts = function() {}; | |
| JQConsole.prototype.ResetMatchings = function() {}; | |
| JQConsole.prototype.Reset = function() {}; |
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
| // replace the _renderValidatedComponent in react-0.14.0.js with this function | |
| _renderValidatedComponent: function () { | |
| // orginal function | |
| function renderValidatedComponent() { | |
| var renderedComponent; | |
| ReactCurrentOwner.current = this; | |
| try { | |
| renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext(); | |
| } finally { | |
| ReactCurrentOwner.current = null; |
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 postgis | |
| (:require [clj-json.core :as json]) | |
| (:use korma.core korma.db korma.sql.engine)) | |
| (defn intersects [first-geom second-geom] | |
| "An extended Korma predicate that uses the PostGIS function ST_Intersects." | |
| (sql-func "ST_Intersects" first-geom second-geom)) | |
| (defn from-wkt [wkt] | |
| "Create a PostGIS geometry with geographic SRID from WKT using ST_GeomFromText." |
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
| (function() { | |
| // Do not use this library. This is just a fun example to prove a | |
| // point. | |
| var Bloop = window.Bloop = {}; | |
| var mountId = 0; | |
| function newMountId() { | |
| return mountId++; | |
| } |
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
| (def m-chan (chan (sliding-buffer 100))) | |
| (def map-state (r/atom {:pressed? false ; if mouse down is pressed? | |
| :transform-map [1 0 0 1 0 0] ; transform map position ;TODO: add zoooming | |
| :start-point {:x 0 :y 0} ; start point for move the map | |
| :end-point {:x 0 :y 0} ; last point for map move | |
| :move-point {:x 0 :y 0}})) ; current point of map move | |
| (defn pan [x y] | |
| (swap! map-state update-in [:transform-map] assoc 4 x 5 y)) |
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
| (def transform-state (reagent/atom [1 0 0 1 0 0])) | |
| (def start-point (reagent/atom nil)) | |
| (def mouse-down? (reagent/atom false)) | |
| (def mouse-chan (chan)) | |
| (defn pan [x y] | |
| (swap! transform-state assoc 4 x 5 y)) | |
| (defn drag-map [] | |
| (go (while true |
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
| trait Enum { //DIY enum type | |
| import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia | |
| type EnumVal <: Value //This is a type that needs to be found in the implementing class | |
| private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values | |
| //Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal | |
| private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS} | |
| val oldVec = get |
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
| (declare *map*) | |
| (def user-events (atom [])) | |
| (defn handler-events [res] | |
| ;; clear markers from the map | |
| (doseq [e @user-events] | |
| (.setMap (:marker e) nil)) | |
| (let [m (map #(assoc % :marker (event-marker %)) res)] | |
| (reset! user-events m))) |