Skip to content

Instantly share code, notes, and snippets.

@valpackett
Created November 10, 2011 17:48
Show Gist options
  • Save valpackett/1355558 to your computer and use it in GitHub Desktop.
Save valpackett/1355558 to your computer and use it in GitHub Desktop.

Revisions

  1. Grigory V. revised this gist Nov 10, 2011. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,8 @@ First,

    ```shell
    $ [sudo] pip install html2text MacFSEvents
    ```
    ```

    Then launch it and enjoy.

    P.S. guess what, ⌘S works in Evernote.
  2. Grigory V. created this gist Nov 10, 2011.
    13 changes: 13 additions & 0 deletions LICENSE.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    Version 2, December 2004

    Copyright (C) 2011 Grigory V. <[email protected]>

    Everyone is permitted to copy and distribute verbatim or modified
    copies of this license document, and changing it is allowed as long
    as the name is changed.

    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

    0. You just DO WHAT THE FUCK YOU WANT TO.
    7 changes: 7 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    Evernote's Mac client + [Marked](http://markedapp.com/) or similar: basically just setting ~/Documents/Evernote Selection.md to the content text of current note converted from HTML to Markdown.

    First,

    ```shell
    $ [sudo] pip install html2text MacFSEvents
    ```
    31 changes: 31 additions & 0 deletions evernote_selection.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/usr/bin/env python
    import os
    import time
    import codecs
    from html2text import html2text
    from fsevents import Observer, Stream

    home = os.environ["HOME"]
    now = lambda: time.mktime(time.localtime())
    last = now()


    def cb(*args):
    global last
    if now() - last > 1:
    codecs.open(os.path.join(home, "Documents/Evernote Selection.md"), "w", "utf-8") \
    .write(html2text(os.popen("""osascript -e \
    'tell application \"Evernote\"
    if selection is not {} then
    set the_selection to selection
    return HTML content of item 1 of the_selection
    else
    return \"\"
    end if
    end tell'""").read().decode("utf-8")))
    last = now()

    cb()
    observer = Observer()
    observer.schedule(Stream(cb, os.path.join(home, "Library/Application Support/Evernote/data")))
    observer.start()