Skip to content

Instantly share code, notes, and snippets.

View battis's full-sized avatar

Seth Battis battis

View GitHub Profile
@battis
battis / link_to_cell.php
Created July 30, 2017 18:14
Linking to a Cell in a Google Spreadsheet
@battis
battis / open_remote_library.applescript
Last active July 31, 2017 00:35
Reliably Open iTunes Library on a Shared Volume
-- set server connection information here
property serverProtocol : "afp://"
property serverName : "your-server-name-here.local"
property volumeName : "shared-volume-name-here"
-- define the desired library location and save the current library location (http://stackoverflow.com/a/1693973/294171 explains exactly how to generate the appalling hexadecimal value for iTunesLibraryLocation below)
property iTunesLibraryLocation : ""
property libraryLocationPref : "com.apple.iTunes 'alis:1:iTunes Library Location'"
-- try to mount share from server
@battis
battis / path_to_url.php
Last active July 30, 2017 17:58
Apache 2’s CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT Variables
$path = __FILE__;
$url = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ?
'http://' :
'https://'
) .
$_SERVER['SERVER_NAME'] .
$_SERVER['CONTEXT_PREFIX'] .
str_replace(
$_SERVER['CONTEXT_DOCUMENT_ROOT'],
'',
@battis
battis / google-drive-sync.cfg
Created June 18, 2017 15:07
Is Google Drive Syncing? [Blink1]
RED=0
GREEN=255
@battis
battis / example.html
Created March 6, 2017 17:12
Accessing the Canvas APIs via JavaScript
<html>
<body>
<!-- load JQuery: copied and pasted from the JQuery CDN list -->
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script>
/*
* this allows us to make authenticated API requests to Canvas
@battis
battis / canvasDataCli Config.sh
Created January 9, 2017 15:57
bashrc configuration to use canvasDataCli
# configure canvas-data-cli
export CD_API_KEY=keyvalue
export CD_API_SECRET=secretvalue
alias canvasDataCli="canvasDataCli -c path/to/config.js"
function unpackAllCanvasData {
for path in path/to/dataFiles/*
do
filter=$(basename $path)
if [ "$filter" != "schema.json" ]
then
@battis
battis / README.md
Last active June 18, 2017 15:12
Reset the favorite courses for all users in a subaccount in Canvas

Install

  1. Download both files (composer.json and reset-favorites-core.php) into the same directory.
  2. Use composer to install dependencies:
cd path/to/that/directory
composer install
  1. Edit the PHP script to contain your actual $API_URL, $API_TOKEN and $ACCOUNT_ID
@battis
battis / login.svg
Last active August 22, 2016 03:58
Styling Canvas Mobile Login
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@battis
battis / course-card-image.js
Created August 3, 2016 15:08
Overlay Canvas course card with an arbitrary image
/* assume the course ID we're interested in is 3494 */
var id = 3494;
/* layer in CSS to load an arbitrary image */
$('.ic-DashboardCard__header_hero[data-reactid*="$' + id + '"]').css('background-image', 'url("https://skunkworks.stmarksschool.org/skunkworks.png")')
/*
* interesting next steps to consider include...
*
* - Scanning course file directories for a specifically named card image,
@battis
battis / hide-calendar.js
Last active August 24, 2016 02:14
Hide arbitrary course calendar in Canvas
/* imagine we want to remove course ID 863 from the calendar list */
var id = 863;
/* look to see if that calendar is currently enabled */
if ($('#context-list li[data-context="course_' + id + '"] checked').length != 0) {
/* click toggle box to hide (a persistent setting -- should only happen once) */
$('#context-list li[data-context="course_' + id + '"] .context-list-toggle-box').click();
}
/* hide calendar so that it can't be re-enabled -- and won't count against limit of 10 */