Skip to content

Instantly share code, notes, and snippets.

View swbuehler's full-sized avatar

Steven Buehler swbuehler

View GitHub Profile
tell application "System Events"
set rssFeed to XML file "Mac mini Internal:Users:steven:Downloads:stevenwbuehler.wordpress.2014-03-25.xml"
set rssItems to every XML element of XML element "channel" of XML element "rss" of contents of rssFeed whose name is "item"
repeat with thisItem in rssItems
set theTitle to the value of XML element "title" of thisItem
if theTitle is (missing value) then set theTitle to the value of XML element "pubDate" of thisItem
set thepubDate to the value of XML element "pubDate" of thisItem
set theContent to the value of XML element "content:encoded" of thisItem
tell application id "com.evernote.evernote"
create note notebook "Public Blog" with html theContent title theTitle created date (do shell script "date -j -f '%a, %d %b %Y %H:%M:%S %z' " & quote & thepubDate & quote & " '+%A, %B %d, %Y at %r'")
tell application id "com.evernote.evernote"
(* Compile a list of subject dates from the notebooks *)
set theNotebooks to every notebook
set yesterday to (current date) - (time of (current date)) - 1 * days
set today to (current date) - (time of (current date))
set theHTMLBody to {} -- we'll convert this back to a single string at the end
repeat with thisNotebook in theNotebooks
<b>Subject: </b>The Subject<br/>
<b>From: </b>The Sender<br/>
<b>To: </b>Me<br/>
<b>Date Sent: </b>11/18/2013 10:22:56 AM<br/>
tell application id "com.evernote.evernote"
set today to (current date) - (time of (current date)) -- set to today at midnight
set theNotes to every note in notebook "Work-Related" whose creation date ≥ today
repeat with thisNote in theNotes
set theContent to the HTML content of thisNote
set theOffset to the offset of "<b>Date Sent:</b> " in theContent
set theContent to text theOffset thru end of theContent
set theDate to text ((offset of "</b>" in theContent) + 5) thru ((offset of "<br/>" in theContent) - 1) of theContent
set the creation date of thisNote to date theDate
-- Evernote won't sync unless we do some other change, like tagging.
Sub FixReceiptDates()
Dim notebookxml As String
Dim outXML As String
Dim notebookname As Variant
Dim appON As OneNote.Application
Dim notes As MSXML2.DOMDocument60
Dim page As MSXML2.DOMDocument60
Set appON = New OneNote.Application
Function GetSectionByName(ByVal strNotebookName As String, ByVal strSectionName As String)
Dim strNameofNotebook As String
Dim outXML As String
Dim appON As OneNote.Application
Dim docXML As MSXML2.DOMDocument60
Set appON = New OneNote.Application
appON.GetHierarchy GetNotebookByName(strNotebookName), hsSections, outXML, xs2013
Set docXML = New MSXML2.DOMDocument60
docXML.LoadXML (outXML)
Function GetNotebookByName(strnotebook As String)
Dim strNameofNotebook As String
Dim outXML As String
Dim appON As OneNote.Application
Dim docXML As MSXML2.DOMDocument60
Set appON = New OneNote.Application
appON.GetHierarchy "", hsNotebooks, outXML, xs2013
Set docXML = New MSXML2.DOMDocument60
docXML.LoadXML (outXML)
Function ConvertToGMT(LocalTime As Date, GMT_Adjust As Double, Optional Observes As Boolean = True, _
Optional Country As String = "US")
' LocalTime is datetime in local
' GTM_Adjust is the normal number of hours you add to or subtract from GMT to get local standard time
' Function turns hours into minutes in DateAdd operations to accommodate half-hour GMT adjustments
' Country is jurisdiction; use ISO codes or common country name
Dim StartDST As Date
Dim EndDST As Date
@swbuehler
swbuehler / Create PO Reminder.scpt
Created July 24, 2014 15:39
Create a reminder to pick up mail at the post office when their notification email is received
tell application "Reminders"
set newReminder to make new reminder in list "Reminders"
set the name of newReminder to "Pick up mail at Post Office."
set the due date of newReminder to date (date string of (current date) & " at 5:00 PM")
set the remind me date of newReminder to date (date string of (current date) & " at 5:00 PM")
end tell
@swbuehler
swbuehler / OutlookSaveToHTML.vba
Last active August 29, 2015 14:10
Save Outlook mail as HTML with attachments and CSV index
Public Sub savetohtml(myItem As Outlook.MailItem)
On Error Resume Next
Dim objAtt As Outlook.Attachment
Dim fso As FileSystemObject
strPath = "\\psf\Home\Library\Containers\com.bitnami.mampstack\Data\app-5_4_9\apache2\htdocs\email\"
Set fso = CreateObject("Scripting.FileSystemObject")
Open (strPath & "Index.csv") For Append As #1
cleansubject = myItem.Subject
stritemID = myItem.EntryID
myItem.SaveAs Path:=(strPath & stritemID & ".html"), Type:=olHTML