Skip to content

Instantly share code, notes, and snippets.

View swbuehler's full-sized avatar

Steven Buehler swbuehler

View GitHub Profile
@swbuehler
swbuehler / TwitchFollowers.py
Last active April 20, 2022 05:07
Python 3: Get list of followers for a Twitch Channel (replace 'MissEllaCronin' in line 10 with Twitch username)
import json
import sys
import csv
from urllib import request
counter = 0
f = open('followers.csv','w',encoding='utf-8',newline="\n")
mywriter = csv.writer(f,dialect='excel',quoting=csv.QUOTE_MINIMAL)
mywriter.writerow(['Followed At (UTC)','Notifications?','User ID','User Name','User Created At (UTC)','User Updated At (UTC)','Display Name','Logo URL','Bio','User Type'])
@swbuehler
swbuehler / stampPDFs.vba
Created March 13, 2017 17:36
Stamp PDFs using Adobe Acrobat
Sub stampPDFs()
On Error Resume Next
Dim App As CAcroApp
Dim PDDoc As CAcroPDDoc
Dim fso As Scripting.FileSystemObject
Dim jso As Object
Dim i As Long
Dim FileName As String
Dim field As Object
@swbuehler
swbuehler / dailyoutlook.ps1
Created March 13, 2017 16:08
PowerShell - Retrieves and displays daily Outlook appointments.
$olFolderCalendar = 9
$ol = New-Object -ComObject Outlook.Application
$ns = $ol.GetNamespace('MAPI')
$Start = (Get-Date).AddDays(-1).ToShortDateString() + " 00:00"
$End = (Get-Date).AddDays(+1).ToShortDateString() + " 00:00"
$Filter = "[MessageClass]='IPM.Appointment' AND [Start] >= '$Start' AND [End] <= '$End'"
$Appointments = $ns.GetDefaultFolder($olFolderCalendar).Items
$Appointments.IncludeRecurrences = $true
@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 / Daily Google Drive Log.gs
Created May 31, 2017 20:48
Email yourself a daily log of updates to your Google Drive (Google Apps Script, requires
/*
Requires the Moment.js library (Resources > Libraries > 15hgNOjKHUG4UtyZl9clqBbl23sDvWMS8pfDJOyIapZk5RBqwL3i-rlCo). Use the latest version.
*/
function myFunction() {
var moment = Moment.load();
var theHTML = '';
var yesterday = moment().startOf('day').subtract(1,'days').format();
var today = moment().startOf('day').format();
var drive = DriveApp.searchFiles('modifiedDate >= "' + yesterday + '" and modifiedDate < "' + today + '"');
theHTML = '<html><p>The following files were updated on Google Drive yesterday, ' + moment(yesterday).format('MMMM D, YYYY') + ':</p><ul>';
@swbuehler
swbuehler / automatic.gs
Created March 22, 2016 20:35
Google Apps Script for
function myFunction() {
var moment = Moment.load();
var cal = CalendarApp.getCalendarById('[[CALENDAR ID GOES HERE]]');
var token = '[[YOUR AUTOMATIC DEVELOPER TOKEN]]';
var now = new Date();
var start = moment(now).startOf('day').subtract(1,'days').utc().format('X');
var end = moment(now).endOf('day').subtract(1,'days').utc().format('X');
// var start = moment('2015-09-13T00:00:00-04:00').utc().format('X');
// var end = moment('2015-10-16T16:45:59-05:00').utc().format('X');
var url = ('https://api.automatic.com/trip/?limit=250&ended_at__gte=' + start + '&ended_at__lte=' + end);
@swbuehler
swbuehler / gist:8947169
Created February 12, 2014 00:06
WordPress XML to Evernote Items
tell application "System Events"
set rssFeed to XML file "Mac mini HD:Users:steven:Downloads:stevenwbuehler.wordpress.2014-02-09.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
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 "Evernote"
create note notebook "Blog Temp" 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'")
end tell
@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 / code.M
Last active September 28, 2016 13:43
Power Query M code to process JSON file from Twitch.tv Import
let
Source = Json.Document(File.Contents("C:\Temp\missellacronin.json")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"created_at", "notifications", "user"}, {"created_at", "notifications", "user"}),
#"Expanded user" = Table.ExpandRecordColumn(#"Expanded Column1", "user", {"_id", "name", "created_at", "updated_at", "display_name", "logo", "bio", "type"}, {"user._id", "user.name", "user.created_at", "user.updated_at", "user.display_name", "user.logo", "user.bio", "user.type"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded user",{{"created_at", type datetimezone}, {"user.created_at", type datetimezone}, {"user.updated_at", type datetimezone}}),
#"Calculated Local Time" = Table.TransformColumns(#"Changed Type",{{"created_at", DateTimeZone.ToLocal, type datetimezone}, {"user.created_at", DateTimeZone.ToLocal, type datetimezone}, {"user.u
@swbuehler
swbuehler / Ella's Followers.ps1
Last active September 28, 2016 13:36
Twitch.tv: Gather followers for an account
$users = @("stevenwatsonb","missellacronin")
foreach ($user in $users) {
"Fetching $user..."
$url = "https://api.twitch.tv/kraken/channels/$user/follows?direction=ASC&limit=100"
$headers = @{"Client-ID" = "XXXXXXXXXX"}
$feed = Invoke-RestMethod -Uri $url -Headers $headers
$total = $feed._total
"Retrieving $total follower(s) for $user..."
$rows = @()
while (($feed.follows).count -ne 0) {