Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Submit Nanowrimo wordcount from Emacs
(defun count-and-submit ()
(interactive)
(let* ((user-name "username")
(secret-key "secret-key")
(word-count (number-to-string (count-words (point-min) (point-max))))
(hash (secure-hash 'sha1 (concat secret-key user-name word-count)))
(url-request-method "PUT")
(url-request-extra-headers `(("Content-Type" . "application/x-www-form-urlencoded")))
(url-request-data (concat "hash=" hash "&name=" user-name "&wordcount=" word-count)))
(url-retrieve-synchronously "http://nanowrimo.org/api/wordcount")
(message "word count submitted: %s" word-count)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment