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 sb-db.experiments | |
(:require [datascript :as d] | |
[cljs.core.match :refer-macros [match]]) | |
(:require-macros [sb.macros :refer [logc]])) | |
;;; Experiment to see if we can subscribe to database updates using core.match, in order to re-query database and get new data that will be (eventually) passed to a reagent component | |
;;; Initialize | |
(def schema {:show {} |
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
(defn- build-handle-tx | |
"On db update, put updated entity onto update-ch" | |
[ch db] | |
(fn | |
[{:keys [tx-data]}] | |
(let [id (-> tx-data first first) | |
e (ds/entity @db (-> tx-data first first))] | |
(if e (go (>! ch e)))))) | |
(defn get-updates |
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 page (make :div)) | |
(def title (make :h1)) | |
(def article (make :p)) | |
(def ul (make :ul {:color "gray"})) | |
(select title {:color "red"}) | |
(select [page article] {:color "green"}) | |
(select [page ul :li] {:font-weight "bold"}) | |
(def list-select (select [page ul])) |
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 fncards.db.utils | |
(:require [fncards.db.api :as db-api] | |
[datascript :as ds] | |
[cljs.pprint :refer [pprint]] | |
[cljs.core.async :as async :refer [chan <! >! put! take! timeout mult tap pub sub]]) | |
(:require-macros [cljs.core.async.macros :refer [go go-loop]] | |
[fncards.macros :refer [log logr logd logc]])) | |
;; Channel and Subscription |
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
~/Sites/nowthis-2 => $ rlwrap ./start.sh | |
Compiling client js ... | |
Waiting for browser to connect ... | |
Watch compilation log available at: out/watch.log | |
To quit, type: :cljs/quit | |
cljs.user=> (require '[sb.core :as sb] :reload) | |
nil | |
[Acljs.user=(require '[sb.core :as sb] :reload) | |
nil | |
cljs.user=> (+ 1 1) |
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
<input ng-model="filter.search" type="text" /> | |
<select ng-model="filter.category" ng-options="c for c in categories" /> |
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
<input class="input-search" type="text" ng-model="filter.search" name="" id="" value="" /> |
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
var request = require('request') | |
, cheerio = require('cheerio') | |
, async = require('async') | |
, format = require('util').format; | |
var reddits = [ 'ImagesOfSpace' ] | |
, concurrency = 2; | |
async.eachLimit(reddits, concurrency, function (reddit, next) { | |
var links = {}; |
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
// in app.js | |
app.get('/app/js/services/config.js', function(req, res) { | |
routes.getConfig(req, res, configs.angular); | |
}); | |
// in routes/index.js | |
exports.getConfig = function(req, res, angular){ | |
res.setHeader('Cache-Control', 'no-cache'); | |
res.render('config', { | |
clientShortName: angular.clientShortName, |
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
'use strict'; | |
angular.module('crossroadsDonateApp') | |
.directive('formItem', ['$compile', '$http', '$templateCache', function($compile, $http, $templateCache, $rootScope) { | |
var rootScope = $rootScope; | |
var getTemplate = function(contentType) { | |
var templateLoader, | |
baseUrl = 'views/', | |
templateMap = { | |
text: 'form-item-text.html', |