This is an command for Backtick. It posts to current page's URL to pinboard.
This file contains 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
#!/bin/sh | |
# | |
# .git/hooks/commit-msg | |
# | |
# Check for maximum line lengths | |
# | |
# A git hook script to check the commit log message. | |
# Called by "git commit" with one argument, the name of the file | |
# that has the commit message. The hook should exit with non-zero | |
# status after issuing an appropriate message if it wants to stop the |
This file contains 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
(defresource conflict-on-post | |
:post! (fn [ctx] (if (detect-conflict ctx) { ::conflict true})) | |
:respone-with-entity (fn [{conflict ::conflict}] (not conflict)) | |
:handle-no-content (fn [{conflict ::conflict}] | |
(when conflict | |
(-> (as-response "my-regular-response") | |
(assoc :status 409) ;; force status | |
(ring-response))))) |
This file contains 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 base-resource-media-typed | |
{"application/json" | |
{:success false | |
:message "No acceptable resource available"} | |
"application/edn" | |
{:success false | |
:message "No acceptable resource available"}}) | |
(def base-resource | |
{:handle-not-acceptable (media-typed base-resource-media-typed) |
This is a command for Backtick. It posts the current page to pinboard.
This file contains 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 into-context [key value] | |
(when value | |
{ key value })) | |
(ANY "/choice" [] | |
(resource :available-media-types ["text/html"] | |
:exists? (fn [ctx] | |
(into-context :choice | |
(get {"1" "stone" "2" "paper" "3" "scissors"} | |
(get-in ctx [:request :params "choice"])))) |
This file contains 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
(apply str (for [i (range 0 36)] | |
(format "%11s %2s %s\n" | |
(.toPlainString (.pow 2M i)) i (.toPlainString (.divide 1M (.pow 2M i))))))) |
This file contains 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
digraph { | |
node[shape="box", splines=ortho] | |
"start"[shape=circle]; | |
"start" -> "service-available?" | |
"handle-multiple-representations" [peripheries=2]; | |
"handle-ok" [peripheries=2]; | |
"multiple-representations?" -> "handle-multiple-representations" [label = "true"] | |
"multiple-representations?" -> "handle-ok" [label="false"] | |
"handle-no-content" [peripheries=2]; | |
"respond-with-entity?" -> "multiple-representations?" [label = "true"] |
This file contains 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
(defdecision moved-temporarily? handle-moved-temporarily post-to-gone?) | |
(defdecision moved-permanently? handle-moved-permanently moved-temporarily?) | |
(defdecision existed? moved-permanently? post-to-missing?) |
This file contains 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 doc) | |
(defn destructure | |
([_ name then else] [name then else]) | |
([_ name test then else] [name then else])) | |
(defn format-node [node] | |
(when (.startsWith (str node) "handle-") | |
(format "\"%s\" [peripheries=2];\n" node))) |