Github Tweaks and CSON to JSON in Makefiles and Emacs
Posted by ark, ,
I made this Github Tweaks Chrome Extension.

Right now it's tiny, but maybe I'll be adding more to it soon.

I like to keep a pinned tab with my open github issues on it. However I usually end up clicking on that list and opening an issue in the pinned tab, not a new one. This extension makes all the links on the issues list page open in a new window.

Are there any other little changes you'd like to make to the github site?

This one was interesting because I got to learn about MutationObserver.

It was also fun writing a GNU Makefile again after all these years. I've started using cson rather than stupid json and modified emacs to automatically compile-on-save (cos) cson to json (using cson2json from cson-cli) just like coffee does to js files.

I've been liking this Github Notification Helper for Gmail quite a bit. I'd really like it if it could add and remove gmail labels based on if a bug was marked as critical or assigned to me maybe I'll break out the Gmail Apps Script for that one (EDIT: I DID IT! gmail-github-labels).

Here's my emacs lisp function to compile cson to json


(autoload 'coffee-mode "coffee-mode" nil t)
(add-hook 'coffee-mode-hook 'ark-coffee-cos?)
(mapc (lambda (a) (add-to-list 'auto-mode-alist a))
  '(("\\.\\(coffee\\|cson\\)$" . coffee-mode)))

(defun ark-compile-cson ()
  "Compile a cson file to a json file (use npm install -g cson-cli to get cson2json)."
  (interactive)
  (let* ( (input (buffer-file-name))
          (basename (file-name-sans-extension input))
          (output (concat basename ".json"))
          (compile-cmd (concat "cson2json " input " > " output))
          (compiler-output (shell-command-to-string compile-cmd)))
    (if (string= compiler-output "")
      (let ((file-name (coffee-compiled-file-name (buffer-file-name))))
        (message "Compiled and saved %s" output)
        (coffee-revert-buffer-compiled-file output))
      (message "Error compiling"))))

(defun ark-coffee-cos? ()
  "Turn on Compile on Save optionally in coffee script mode"
  (interactive)
  (if (or
        (and (string-match "/mysrc/" (buffer-file-name))
          (not (string-match "\\.cson$" (buffer-file-name))))
        (file-exists-p (concat (file-name-sans-extension (buffer-file-name)) ".js")))
      (coffee-cos-mode t))
  (if (file-exists-p (concat (file-name-sans-extension (buffer-file-name)) ".json"))
    (add-hook 'after-save-hook 'ark-compile-cson nil t)))

Writing this blog post has made me really want to look into moving over to github pages like danvk did....

Comments