View README.md

Generic function which take a handler function and calls it passing in a event map. Typically this will be used with partial to create a dispatch function which is bound to a handler.

(defn dispatch [handler message] 
  (let [event (json/read-str message)]
    (println "<- dispatch" event "to" handler) 
    (handler event)))
View example.sql
# join table, no WHERE
SELECT s.id, tf0.value as iras_id FROM studies s LEFT JOIN text_fields tf0 ON s.id = tf0.study_id AND tf0.text_field_definition_id = (SELECT id from text_field_definitions WHERE `key` = 'csp_number') ORDER BY s.id
# join table, WHERE value in joined table
SELECT s.id, tf0.value as iras_id FROM studies s JOIN text_fields tf0 ON s.id = tf0.study_id AND tf0.text_field_definition_id = (SELECT id from text_field_definitions WHERE `key` = 'csp_number') AND tf0.value = '7713' ORDER BY s.id
# join two tables, no WHERE
SELECT s.id, tf0.value as iras_id, tf1.value as rec_ref FROM studies s JOIN text_fields tf0 ON s.id = tf0.study_id AND tf0.text_field _definition_id = (SELECT id from text_field_definitions WHERE `key` = 'csp_number') JOIN text_fields tf1 ON s.id = tf1.study_id AND tf1.text_field_definition_id = (SELECT id from text_field_definitions WHERE `key` = 'rec_ref') ORDER BY s.id
# join two tables, WHERE value on t1 is X OR on t2 is Y
View FULLTEXT.md

Using MySQL full text queries, in my experience, are not as fast as using Solr/Elastic Search, but do not require the additional provisioning and maintence of a search server.

You need to add a FULL TEXT index on the columns you wish to query.

The questions marks are to be replaced by the query, for example +mental +health.

SELECT *, MATCH (name,summary) AGAINST (? IN BOOLEAN MODE) as score FROM documents WHERE MATCH (name,summary) AGAINST (? IN BOOLEAN MODE) > 0 ORDER BY score DESC;
View wtf.md
mv roles/deploy/drone-deployment roles/deploy/drone
mv roles/deploy/transparent-proxy-deployment roles/deploy/transparent-proxy
git status
deleted:    roles/deploy/drone-deployment/tasks/apachesite.yml
deleted:    roles/deploy/drone-deployment/tasks/deployer_name.yml
deleted:    roles/deploy/transparent-proxy-deployment/tasks/apachesite.yml
View HOW.md
{% if https %}
<VirtualHost *:80>
  ServerName {{ domain }}
  {% for alias in domain_aliases %}
  ServerAlias {{ alias }}
  {% endfor %}

  RewriteEngine On
  {% if letsencrypt %}
View for.md

This will not work as expected, no users will be created.

(defn populate-users []
  (when (empty? (select-users db))
    (for [user hashed_users]
             (insert-user db user))))

This is because for returns a lazy collection, it does not evaludate until it is realized.

View create-users.sql
CREATE TABLE users (
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(255),
email VARCHAR(255),
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
)
View 00-NOTES.md

Ring handler a function which accepts a request (map) and returns a response (map).

Ring middleware

function (handler, &args -> function(request -> response) because it is a closure handler and &args are in scope within the returned handler function.

a function which accepts a "next handler" (the next handler in the chain) + any extra arguments and returns a handler (function), which will accept a request and return a response.

View README.md
class FirstPublisher
  include Wisper::Publisher
  include Wisper::Bubble

  def call
    broadcast(:it_happened)
  end
end
View 00-INTRO.md

I wanted a function to convert given keys in a vector and maps from true/false to "yes"/"no".

[{ :is_it true } { :is_it false }] ;; => [{ :is_it "Yes" } { :is_it "No" }]

Note I use boolean? which was added to Clojure 1.9, it can be replaced with (instance? Boolean bool) in 1.8.