Skip to content

Instantly share code, notes, and snippets.

(ns streaker-service.routes
(:require [io.pedestal.http.route :as route]
[io.pedestal.http.body-params :as body-params]
[io.pedestal.http.route.definition :refer [expand-routes]]
[ring.util.response :as ring-resp]
[streaker-service.api :as api]
[streaker-service.page :as page]
[streaker-service.pedestal-util :as pedestal-util]
[streaker-service.models.question :as question]
[streaker-service.models.friend :as friend]))
@dustingetz
dustingetz / gist:412aca3fc17dc2c73ebd
Created January 19, 2015 19:14
MultiSelectCheckBox
define([
'underscore.mixed', 'react', 'wingspan-forms', 'wingspan-contrib'
], function (_, React, Forms, Contrib) {
'use strict';
var MultiSelectCheckbox = React.createClass({
displayName: 'MultiSelectCheckbox',
statics: { fieldClass: function () { return 'formFieldCheckbox'; } },
;; the route currently maps to this ring handler
(fn [{{:keys [tx]} :query-params {:keys [id]} :path-params}]
(ring-resp/response
(api/entity-read item-route
(Long/parseLong id)
(Long/parseLong tx)
typeinfo)))
(defn entity-read [item-route eid tx typeinfo]
(with-db-as-of tx
(defn mk-item-get [item-route typeinfo]
(fn [{{:keys [tx]} :query-params {:keys [id]} :path-params}]
(-> (api/entity-read (Long/parseLong id) (Long/parseLong tx))
(#(cj/item item-route [] % typeinfo tx))
ring-resp/response)))
// type is: Cursor[List[T]] => List[U]
function map_cursor_list (cur, f) {
return map_indexed(cur.value, function (i, v) {
return f(cur.refine(i));
});
}
function map_indexed (list, f) {
return map(zip(range(list.length), list), function (pair) {
return f(pair[0], pair[1]);
@dustingetz
dustingetz / gist:3b9e4a37ab3837a1e6a6
Last active August 29, 2015 14:14
url_resovler.clj
(ns streaker-service.url-resolver
(:require [streaker-service.service]
[streaker-service.server :refer [service-instance]]
[io.pedestal.http :as bootstrap]
[io.pedestal.test :refer [test-servlet
test-servlet-request
test-servlet-response
test-servlet-response-status
test-servlet-response-headers]]))
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
{:client-uuid "3" :time-stamp 12345 :type "mousemove" :clientX 245 :clientY 144}
query("log entry 12345 join domevent 1234").clientX
{:client-uuid "1" :time-stamp 1234 :type "dombodychange" :html "{:node-name \"body\" :attributes {}}"}
{:client-uuid "2" :type "mousemove"}
-- :: Integer -> Maybe Integer
f0 = \x -> Just (x + 1)
f1 = \x -> Just (x + 10)
f2 = \x -> Just (x + 100)
g0 = \_ -> Nothing -- failure
Just 0 >>= f0
Just 1
Just 0 >>= f0 >>= f1 >>= f2
@dustingetz
dustingetz / gist:6db0e52da06eb673a6b0
Created May 14, 2015 17:04
hypercrud master detail editor
(let [master-detail-cur (cur [:app :master-detail] {:form {}})]
[:fieldset
[:legend "livecoding demo"]
(let [root-hc-node {:href "/api?prod=true"}]
[hypercrud/resolve client root-hc-node
(fn [root-hc-node']
(if (not (hypercrud/loaded? client root-hc-node'))
[:h1 "Loading root node"]
[hypercrud/resolve client (-> root-hc-node' :links :communities)
var entry_hc_node = {href: "/api?prod=true"};
hypercrud_client.resolve(entry_hc_node, function (entry_hc_node) {
var communities = entry_hc_node.links.communities;
return hypercrud_client.resolve(communities, function (communities) {
var communities_dom = communities.data.map(function (community) {
return hypercrud_client.resolve(community, function (community) {
return <li>{community.data["community/name"]</li>;
});
});
return <ul>{communities_dom}</ul>;