Skip to content

Instantly share code, notes, and snippets.

@fangzhzh
Created November 27, 2015 08:41
Show Gist options
  • Save fangzhzh/dbf5785627a5a8c7a676 to your computer and use it in GitHub Desktop.
Save fangzhzh/dbf5785627a5a8c7a676 to your computer and use it in GitHub Desktop.
0 1 * * * curl https://gist.githubusercontent.com/fangzhzh/7f9ed840948e81b7fc76/raw/30f2bf8dc7606ed6d8746ec8db745fb57f42c7c5/journal_with_remind.py | python
0 1 * * 1 curl https://gist.githubusercontent.com/fangzhzh/7f9ed840948e81b7fc76/raw/30f2bf8dc7606ed6d8746ec8db745fb57f42c7c5/journal_with_remind.py | python /dev/stdin week
0 1 1 * * curl https://gist.githubusercontent.com/fangzhzh/7f9ed840948e81b7fc76/raw/30f2bf8dc7606ed6d8746ec8db745fb57f42c7c5/journal_with_remind.py | python /dev/stdin month
__author__ = `who | awk '{print $1}'`
from evernote.api.client import EvernoteClient
import evernote.edam.type.ttypes as Types
import datetime, sys
dev_token = "$DEV_TOKEN_GET_FROM_EVERNOTE"
client = EvernoteClient(token=dev_token, sandbox=False)
userStore = client.get_user_store()
user = userStore.getUser()
noteStore = client.get_note_store()
note = Types.Note()
note.notebookGuid = "066774b5-4b38-43ea-a25b-12c981c3d97c" ## GUID OF notebook
note.content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
note.content += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
# noteStore = client.get_note_store()
# notebooks = noteStore.listNotebooks()
# for n in notebooks:
# print n.name
# print n.guid
#
# exit
if len(sys.argv) <= 1 or sys.argv[1] == 'day':
noteboy = "<div>## family ##</div>"
noteboy += "<div>## work ##</div>"
noteboy += "<div>## English ##</div>"
noteboy += "<div>## friends ##</div>"
noteboy += "<div>## exercise ##</div>"
note.content += "<en-note>%s</en-note>" % noteboy
dateTime = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %A %H:%M:%S journal')
note.tagNames = ["journal"]
note.title = dateTime
elif sys.argv[1] == 'week':
noteboy = "## done ##<br></br>"
note.content += "<en-note>%s</en-note>" % noteboy
now = datetime.date.today()
weekdelta = datetime.timedelta(days=7)
lastWeek = now - weekdelta
note.tagNames = ["journal", "week_review"]
note.title = "Weekly review: " + str(now) + "->" + str(lastWeek) + " Week " + str(lastWeek.isocalendar()[1])
elif sys.argv[1] == 'month':
noteboy = "## done ##<br></br>"
note.content += "<en-note>%s</en-note>" % noteboy
note.tagNames = ["journal", "month_review"]
now = datetime.date.today()
note.title = "monthly review: " + str((now.month -1))
attributes = Types.NoteAttributes()
start_time = datetime.datetime(1970,1,1)
c = datetime.datetime.utcnow() - start_time
milliseconds = (c.days * 24 * 60 * 60 + c.seconds) * 1000 + c.microseconds / 1000.0 + 60000;
attributes.reminderTime = milliseconds
note.attributes = attributes
created_note = noteStore.createNote(note)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment