Skip to content

Instantly share code, notes, and snippets.

View swbuehler's full-sized avatar

Steven Buehler swbuehler

View GitHub Profile
@swbuehler
swbuehler / Pull Receipts.scpt
Created December 16, 2015 02:53
Pulls receipt metadata from file comments into a Numbers spreadsheet
tell application "Numbers"
set theSpreadsheet to (make new document with properties {document template:template "Receipt List"})
set theTable to table 1 of sheet 1 of theSpreadsheet
end tell
tell application "Finder"
set theFiles to every file of folder "Internal:Users:steven:Documents:Receipts"
repeat with thisFile in theFiles
set theComment to the comment of thisFile
tell application "System Events"
do shell script "echo " & the quoted form of theComment & " > /tmp/json.json"
@swbuehler
swbuehler / read json comments.scpt
Created December 16, 2015 02:43
Reads the text from an associated file and posts it as the comments for a Finder file
tell application "Finder"
set theFiles to every file of folder "Internal:Users:steven:Documents:Receipts"
repeat with thisFile in theFiles
set |filename| to the name of thisFile
set |metadata| to (open for access file ("|filename|" & ".json") with read access)
set the comment of thisFile to (read |metadata|)
close access |metadata|
end repeat
end tell
@swbuehler
swbuehler / description-to-json.gs
Last active December 16, 2015 02:41
Export Google Drive file descriptions to associated text/JSON file.
function myFunction() {
var receiptDirectory = DriveApp.getFolderById("<your receipt folder's ID here>");
var receipts = receiptDirectory.getFiles();
while receipts.hasNext(){
var receipt = receipts.next();
DriveApp.createFile(receipt.getName() + '.json', receipt.getDescription(), 'text/json');
}
}
@swbuehler
swbuehler / Evernote Reminders to Apple Reminders.scpt
Created October 23, 2015 14:15
Copy Evernote reminders to Apple Reminders
(* Change line 12 to the name of the Reminders List you want to copy to (here I've used "Finances") *)
tell application "Evernote"
set theNotes to (find notes "reminderorder:* -reminderdonetime:*")
repeat with thisNote in theNotes
set reminderTime to the reminder time of thisNote
set reminderTitle to the title of thisNote
set reminderURL to the note link of thisNote
tell application "Reminders"
set theReminders to (every reminder whose due date is reminderTime and name is reminderTitle)
@swbuehler
swbuehler / automatictocalendar.gs
Last active May 24, 2018 13:36
Process data from Google Sheets into Google Calendar
/*
This Google Script requires the moment.js library to parse IFTTT's date format.
Go to the script menu and select "Resources > Libraries" and search for Library ID 'MHMchiX6c1bwSqGM1PZiW_PxhMjh3Sh48'.
*/
function myFunction() {
// initialize references and starting variables
var moment = Moment.load();
var cal = CalendarApp.getCalendarById("ipovguj4o6k6r3cg1r89d9ieis@group.calendar.google.com");
@swbuehler
swbuehler / encodeQRTiff.scpt
Created September 15, 2015 17:14
Add QR Code to multipage TIFF files containing the full path to the filename.
tell application "Finder"
set theFiles to the selection
repeat with thisFile in theFiles
try
(* get path and filename information from UNIX *)
set theExtension to the name extension of thisFile
set thePath to the POSIX path of (folder of thisFile as string)
set theFilename to the POSIX path of (thisFile as string)
set theBaseName to (do shell script "/bin/bash -c \"basename " & theFilename & " ." & theExtension & "\"")
set theURLEncodedFilename to (do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theFilename)
@swbuehler
swbuehler / Process Barcoded Documents.scpt
Last active September 13, 2015 16:20
Read QR code with filepath to rename and move selected scans
tell application "Finder"
set theFiles to the selection
repeat with thisFile in theFiles
try
set thePath to the POSIX path of (thisFile as string)
set theExtension to the name extension of thisFile
set theScanResult to (do shell script "/usr/local/bin/zbarimg -q " & the quoted form of thePath)
if the length of theScanResult > 0 then
set theNewFilename to text 9 thru -1 of theScanResult
set theNewPath to (do shell script "/bin/bash -c \"dirname " & the quoted form of theNewFilename & "\"")
Sub CCCR_Client_Reports_by_State_20150812()
Dim wb As Workbook
Dim ws As Worksheet
inputFile = MyDocs & "\Client Reporting\CCCR Query List.csv"
Open inputFile For Input As #1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Do While Not EOF(1)
Input #1, ClientName, ClientSQL
Set wb = Workbooks.Open(MyDocs & "\Client Reporting\Templates\New Formats\CCCR - General Template.xlsx")
@swbuehler
swbuehler / fixoutlookemail.vba
Last active August 29, 2015 14:25
VBA: OneNote: Change page date to match date of Outlook Email
Sub FixOutlookEmail()
Dim notebookxml As String
Dim outXML, pageXML 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
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed