Skip to content

Instantly share code, notes, and snippets.

View StewartJohn's full-sized avatar

John Stewart StewartJohn

View GitHub Profile
@StewartJohn
StewartJohn / statusCheck.py
Created July 2, 2019 16:06
Check HTTP Status of a csv list of URLS
import urllib3
import os
import csv
rows = []
http=urllib3.PoolManager()
#load the csv list of URLs to check
with open('urls.csv', 'r') as input:
csv_reader = csv.reader(input)
for blog in csv_reader:
@StewartJohn
StewartJohn / CollectAnnotations.gs
Last active May 24, 2016 17:51
This Google Scripts code passes parameters from a Google Spreadsheet to the Hypothes.is API. It then parses the API's json into a new sheet. On a third sheet it builds a table of users and URLs and runs countifs formulas to count annotations by user by url. Here's a link to a blog post about the project: www.johnastewart.org/tools/hypothes-is-co…
function collectAnnotations() {
var sheet = SpreadsheetApp.getActiveSheet();
var values = sheet.getRange(7, 5, 4).getValues(); // create array of parameters set by the user by generating an array from row 7, column 5 for 3 rows
// parsing the array of parameters set by the user
var user = values[0];
var url = values[1];
var tag = values[2];
var anyField = values[3];
@StewartJohn
StewartJohn / reclaim_status_check.php
Created February 25, 2016 20:04
Check the Reclaim API status of a server and publish it to WordPress
<?php
$response = wp_remote_get( 'http://status.reclaimhosting.com/api/v1/components' ); //use HTTP GET to retrieve server status information from the API
if( is_array($response) ) {
$body = $response['body']; // use the content
$a = json_decode($body, true); //parse the json from the HTTP GET
$serverName1 = $a[data][7][name]; //Set a variable called serverName1 equal to the name attribute for the 7th item in the Server List
$status1 = $a[data][7][status_name]; //Set a variable called status1 equal to the status_name attribute for the 7th item in the Server List
$serverName2 = $a[data][15][name]; //Set a variable called serverName2 equal to the name attribute for the 15th item in the Server List
$status2 = $a[data][15][status_name]; //Set a variable called status2 equal to the status_name attribute for the 15th item in the Server List
if( $status1=="Operational") {
@StewartJohn
StewartJohn / postconnections.php
Last active October 20, 2015 21:02 — forked from billerickson/gist:1624373
Manually Curated Related Posts - Establish the Connection
<?php
/**
* Related Post Connection
* Forked from:
* @author Bill Erickson
* @link http://www.billerickson.net/manually-curated-related-posts/
*
* @uses Posts2Posts
* @link https://github.com/scribu/wp-posts-to-posts/wiki
@StewartJohn
StewartJohn / pug-bomb.php
Last active September 10, 2015 14:49 — forked from retgef/pug-bomb.php
Pug Bomb API Endpoint WordPress Plugin
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{