Created
October 22, 2016 00:21
-
-
Save brool/cf150f0f248b44dc676ef4dc17e65664 to your computer and use it in GitHub Desktop.
Submit Nanowrimo wordcount from Emacs
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
(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