Skip to content

Instantly share code, notes, and snippets.

@jorgenschaefer
Last active April 10, 2016 17:18
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 jorgenschaefer/cd9cbc05864e6a8f037f018c8e7a656f to your computer and use it in GitHub Desktop.
Save jorgenschaefer/cd9cbc05864e6a8f037f018c8e7a656f to your computer and use it in GitHub Desktop.
(require 'json)
(require 'subr-x)
(defun fix-string (s)
(string-join
(delq nil (mapcar (lambda (ch)
(encode-coding-char ch 'utf-8 'unicode))
s))))
(with-current-buffer (url-retrieve-synchronously
"http://gnufans.net/~fsbot/data/botbbdb")
(goto-char (point-min))
(re-search-forward "^$")
(let ((entries nil))
(condition-case err
(while t
(let* ((entry (read (current-buffer)))
(name (fix-string (elt entry 0)))
(data (elt entry 7))
(timestamp (cdr (assq 'timestamp data)))
(notes (let ((n (cdr (assq 'notes data))))
(if (stringp n)
n
(format "%s" n))))
(parsed (mapcar 'fix-string (read notes))))
(push `((name . ,name)
(timestamp . ,timestamp)
(data . ,parsed))
entries)))
(end-of-file
nil))
(write-region (json-encode entries)
nil
"/tmp/fsbot.json")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment