Skip to content

Instantly share code, notes, and snippets.

View troutcolor's full-sized avatar

John Johnston troutcolor

View GitHub Profile
@troutcolor
troutcolor / postto-micro.blog.scpt
Last active April 12, 2019 02:10
This is a script for alfred to post to a WordPress, adding the category micro, post format status and as a note. There is no title. I use a hotkey cmd-alt-cnrl-m alfred passes the selected text in the topmost app to the script as q. I don't deal with special chars. Password hard coded is probably not a good idea. Obviously you could edit categor…
on alfred_script(q)
set myBlogUsername to "USERNAME"
set myBlogPass to "PASSWORD"
set cat to {category:{"Micro"}, kind:{"note"}}
set poststrut to {post_type:"post", post_status:"publish", post_format:"status", post_title:"", post_content:q, terms_names:cat, comment_status:"open"}
tell application "http://example.com/xmlrpc.php"
set myPosts to call xmlrpc {method name:"wp.newPost", parameters:{"1", myBlogUsername, myBlogPass, poststrut}}
return myPosts
end tell
end alfred_script
@troutcolor
troutcolor / micro.blog-fave-images.scpt
Last active February 10, 2019 13:18
AppleScript Get your favourites from micro.blog find photos and make thumbnail grid needs JSON Helper and an app token from your micro.blog account
(*
* Inspired by smokey
* https://gist.github.com/sardisson/e50286e17c8f2f39bfec9429ed5f46cd
* url for thubnail from @smokey too
* html Thumbnail image griid from Micro.blog favs
* NEEDS JSON Helper free from
*https://itunes.apple.com/gb/app/json-helper-for-applescript/id453114608?mt=12
* Needs a App token from micro.blog/account
* NO ERROR CHECKING
* updated to use cloudimage you need a token from cloudimage.io iin CLOUDIMAGETOKEN below.
@troutcolor
troutcolor / OnThisDay.php
Last active February 1, 2019 17:26
simple shortcode plugin to display posts from the current day. I put it in a folder onthisday inside my plugins folder. Then make a page and add [onthisday] NB thewre are a few problems with thiis, use https://github.com/cogdog/wp-posted-today instead.
<?php
/*
There are some problems with this, use https://github.com/cogdog/wp-posted-today instead.
*/
/*
* Plugin Name: OnThisDay
* Description: shortcode for posts on the current day
* Version: 0.1
* Author: John Johnston
* Mostly borrowed from https://wordpress.stackexchange.com/questions/53462/on-this-day-php-code/53761
@troutcolor
troutcolor / feed-microcast.php
Created August 6, 2018 09:19
WordPress RSS feed template for my microcast
<?php
/**
* RSS2 Feed Template for displaying RSS2 Posts feed.
* Modified for microcast
* Based on template found https://css-tricks.com/roll-simple-wordpress-podcast-plugin
*
*/
$numposts = 50; // number of posts in feed
$posts = query_posts('showposts='.$numposts.'&cat=652');
@troutcolor
troutcolor / downloadWordPressMedia.scpt
Created June 2, 2018 17:43
downloads media from WordPress site using AppleScript and the REST API
--needs json helper for apple script Free from mac app store
--https://itunes.apple.com/gb/app/json-helper-for-applescript/id453114608?mt=12
set downloadfolder to POSIX path of (choose folder with prompt "Please select an output folder:")
set pagecountstart to 1
set pagecountmax to 1
set perpage to 10 --MAX =100
set blogurl to "FILL-IN-THE-URL"
@troutcolor
troutcolor / pinboardToLinks.scpt
Created October 20, 2017 14:17
An appleScript that pulls recent links from pinboard, make a html list from the and opens in BBEdit ready to edit and post to blog. lins in the description beginning with > are made into blockquotes.
@troutcolor
troutcolor / quicknote.js
Created September 24, 2017 11:32
Make a new browser window where you can type. I run from bookmarket or via FastScripts
window.open('data:text/html, %3Chtml%20contenteditable%3E%3Cstyle%3E%2A%7Bfont-size%3A20px%7D%3C%2Fstyle%3E','_blank')
//window.open('data:text/html, <html contenteditable><style>*{font-size:20px}</style>','_blank')
@troutcolor
troutcolor / boos-to-blog.scpt
Last active September 14, 2017 19:48
After downloading the json of a set of boos via the audioboo api and downloading and re-uploading the associated mp3s this AppleScript creates posts on my blog for all of the mp3s using the descriptions, dates tags etc from AudioBoo(m)
--mp3s have been downloaded and then uploaded to a folder on the web
--I could not manage to create enclosures on blog posts with AppleScript
global myBlogUsername, myBlogPass, myBlogPass, boonote, mp3uploadfolder, boojson
set myBlogUsername to "USERNAME"
set myBlogPass to "PASSWORD"
set boonote to "<em>This audio file was orginally posted to AudioBoo(m) with the mobile app. It has been downloaded and posted here since audioboom no longer supports free accounts.</em>"
set mp3uploadfolder to "http://johnjohnston.info/exboos/"
set boojson to (read POSIX file "Users/john/Desktop/audioboom/johnjohnston.json")
@troutcolor
troutcolor / downloadboos.scpt
Last active September 9, 2017 19:21
AppleScript to download mp3s with particular tag from AudioBoom. Also save json with post info to file
set downloadfolder to "/Users/john/Desktop/audioboom/edutalk/"
--so this next bit could be a loop but doing it manual was not much of a hassle
set pagecount to 9
set tag to "edutalk"
set itemcount to 100
tell application "JSON Helper"
set bURL to "https://api.audioboom.com/tag/" & tag & "/audio_clips?page[items]=" & itemcount & "&page[number]=" & pagecount
set boos to fetch JSON from bURL
set myFile to open for access "Macintosh HD:Users:john:Desktop:audioboom:edutalk_" & pagecount & ".json" with write permission
@troutcolor
troutcolor / auto-complete-gifs
Last active February 12, 2017 10:35
Makes auto complete google search gifs, needs gifsicle
--needs gifsicle http://www.lcdf.org/gifsicle/
-- updated for retina screen
set thetext to text returned of (display dialog "What do you want to autocomplete?" default answer "I hate")
set theFileName to change_case_of(thetext, "lower") & ".gif"
set tempdir to POSIX path of (path to temporary items from user domain) & "autogifs/"
try
do shell script "mkdir " & tempdir
end try