Skip to content

Instantly share code, notes, and snippets.

View swbuehler's full-sized avatar

Steven Buehler swbuehler

View GitHub Profile
@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) {
@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'])
{
"StartTime" : "{{UpdatedAt}}",
"EndTime" : "{{UpdatedAt}}",
"Event" : "Posted to Facebook: {{Message}}",
"Location" : "",
"Description" : ""
}
function doPost(e) {
moment = Moment.load();
var cal = CalendarApp.getCalendarById('<<CALENDAR ID>>@group.calendar.google.com');
var postContent = e.postData.getDataAsString();
var json = JSON.parse(postContent);
var startTime = moment(json.StartTime,'MMMM DD, YYYY at hh:mmA').local().toDate();
var endTime = moment(json.EndTime, 'MMMM DD, YYYY at hh:mmA').local().toDate();
var event = json.Event.toString();
@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 / read_yaml.scpt
Created December 26, 2015 19:03
Reads separate .yaml file into Finder comments, deletes .yaml file.
tell application "Finder"
set theYAMLs to the selection
repeat with thisYAML in theYAMLs
set theName to the name of thisYAML
set theName to (text 1 thru -6 of theName)
set thePath to the POSIX path of (thisYAML as string)
repeat with thisExtension in {".pdf", ".tiff", ".tif", ".png", ".jpg"}
try
set theAssociatedFile to file (theName & thisExtension) of the folder of thisYAML
end try
Receipt:
- Vendor: USAA Insurance
Account: Joint Checking
Date: 12/10/2015
Amount: 172.41
SalesTax: 0
Confirmation: 572421096
- Vendor: Ally Financial
Account: Joint Checking
Date: 12/11/2015
{
"Receipt": [{
"Vendor":"USAA Insurance",
"SalesTax":0,
"Amount":172.41,
"Account":"Joint Checking",
"Date":"12/10/2015 10:32"
},{
"Vendor":"Ally Financial",
"SalesTax":0,
Receipt:
- Vendor: Walmart #1960
SalesTax: 0.35
Amount: 10.01
Account: [EBT, Cash, 3898]
Date: 10/16/2015 17:41:35
{
"Receipt": {
"Vendor":"Walmart #1960",
"SalesTax":0.35,
"Amount":10.01,
"Account":["EBT","Cash","3898"],
"Date":"10/16/2015 17:41:35"
}
}