View smartadmin.haml
%div#incomplete-task-widget.jarviswidget.jarviswidget-color-blueDark{ data: { "widget-fullscreenbutton" => "true" }, role: 'widget' }
%header{ role: 'heading' }
%h2 Todo
%div.widget-toolbar{ role: 'menu' }
%div.label.label-info
= @incomplete_tasks.size
-# %div.widget-toolbar{ role: 'menu' }
-# %a.btn.btn-primary My Tasks
%div{ role: 'content' }
View wisper.md

It has been over 4 years since I wrote Wisper. In that time I have learned much.

Firstly, Wisper 2.x:

Wisper 2.x will continue to be supported indefinitely. This is quite possible because features will be frozen and since Wisper is a Ruby gem it only need work if Ruby itself contains breaking changes. This means there is no requirement, or motivation, to upgrade existing projects.

Gems which depend on Wisper, e.g. wisper-rspec, wisper-activejob etc. should depend on wisper 2.x, and a new version, 3.x, should be created to support wisper 3.x (even if there are no code changes). I would like to give the commit bit to other contributors to maintain these projects. Please get in touch if you are interested.

Wisper 3.x

View wisper-transaction.md
class CreateStudy

  def call(attributes)
    study = Study.new(attributes)

    ActiveRecord::Base.transaction do
      begin
        study.save!
        raise "something bad happens here"
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()
)