- Get evaluation license key : http://my.datomic.com/eval/request
- Download pro version : http://downloads.datomic.com/pro.html
- Dev mode setup
| (ns strum.core | |
| (:refer-clojure :exclude [defn]) | |
| (:require | |
| [clojure.spec :as spec] | |
| [clojure.spec.test :as spec.test])) | |
| ;; --------------------------------------------------------------------- | |
| ;; Prelude | |
| ;; HACK: Currently, as of Clojure 1.9.0-alpha14, there is a bug with |
| (extend-type js/RegExp | |
| cljs.core.IFn | |
| (-invoke ([this s] (re-matches this s)))) | |
| (#"foo.*" "foobar") ;=> "foobar" | |
| (#"zoo.*" "foobar") ;=> nil | |
| (filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz") |
| (extend-type js/RegExp | |
| cljs.core.IFn | |
| (-invoke ([this s] (re-matches this s)))) | |
| (#"foo.*" "foobar") ;=> "foobar" | |
| (#"zoo.*" "foobar") ;=> nil | |
| (filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz") |
| (eval((fn[program](let [n (zipmap '(+ - > < . ?)(repeatedly gensym))](letfn[(f*[ | |
| s] (if (vector? s) `(while (not (~(n '?))) ~@(map f* s)) `(~(n s))))]`(let [t# ( | |
| int-array 100 0)pt# (atom 0)a#(fn[c#]#(aset t# @pt#(c# (aget t# @pt#))))b#(fn[d# | |
| ]#(swap! pt# d#)) ~(vec (map n '(+ - > <)))(map #(%1 %2)[a# a# b# b#](cycle [inc | |
| dec]))~(n '.)#(print(char(aget t# @pt#)))~(n '?)#(zero?(aget t# @pt#))]~@(map f* | |
| (read-string(str "("(->> program (interpose \space) (apply str)) ")" )))))))"+++ | |
| +++++[>++++++++<-]>+.[>+<-]+++++[>-----<-]>--------.[>+<-]++++++++[>++++++++<-]> | |
| ++++++++++++.+++.+++++.[>+<-]+++++++++[>---------<-]>---.[>+<-]++++++++[>+++++++ | |
| +<-]>+++++++++++++++.---------.[>+<-]++++++++[>--------<-]>------.[>+<-]++++++++ | |
| [>++++++++<-]>++++++++.-------.++.++++++++.--.+++++.-------.[>+<-]++++++++[>---- |
| javascript: (function () { | |
| function c() { | |
| var e = document.createElement("link"); | |
| e.setAttribute("type", "text/css"); | |
| e.setAttribute("rel", "stylesheet"); | |
| e.setAttribute("href", f); | |
| e.setAttribute("class", l); | |
| document.body.appendChild(e) | |
| } | |
| function h() { |
| # My take on Mike's source_for method. | |
| # (see http://pragmaticstudio.com/blog/2013/2/13/view-source-ruby-methods) | |
| # | |
| # (1) I named it 'src' rather than source_for (ok, I'm a lazy typer). | |
| # (2) The edit function was broken out as a separate function. | |
| # (3) The edit function is for emacs | |
| # (4) If the method is not defined on the object, and the object | |
| # is a class, then see if it is an instance method on the class. | |
| # | |
| # The fourth point allows my to say: |
| ;; Datomic example code | |
| ;; | |
| ;; The extent of entity ?x is all datoms that are about ?x. | |
| ;; Drop this into your rules. | |
| ;; | |
| ;; Demonstrates | |
| ;; | |
| ;; 1. recursive query (extent calls itself) | |
| ;; 2. disjunction (different extent bodies are ORed) | |
| ;; 3. component attributes (e.g. your arm is a component, your brother isn't) |
| ;; It all started here: http://clojure-log.n01se.net/date/2011-04-06.html#19:04 | |
| (#((% (+(*))) %) ;; call arg 1 with all args | |
| [;; data | |
| (+ (*)(*)(*)(*)(*)(*)(*)) | |
| ;; main fn -- simulate 'if' with map lookup and closures | |
| #(({(+) (% (+(*)(*)))} ;; if zero return 'then' clause | |
| (% (+)) ;; dispatch on first arg | |
| (% (+(*)(*)(*)))) ;; call 'else' clause (n not found in map) | |
| %) |
| class Document < ActiveRecord::Base | |
| after_save :index_record | |
| before_destroy :remove_from_index | |
| private | |
| def to_solr | |
| #TODO - implement a hash serialization of this record | |
| end | |
| def index_record | |
| SolrService.add(self.to_solr) |