Skip to content

Instantly share code, notes, and snippets.

@brool
Created October 22, 2016 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brool/cf150f0f248b44dc676ef4dc17e65664 to your computer and use it in GitHub Desktop.
Save brool/cf150f0f248b44dc676ef4dc17e65664 to your computer and use it in GitHub Desktop.
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