Skip to content

Instantly share code, notes, and snippets.


Lance E Sloan «UMich» lsloan

  • @tl-its-umich-edu - Teaching & Learning, ITS, Univ. of Michigan
  • Ann Arbor, Michigan, USA
Block or report user

Report or block lsloan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lsloan /
Created Jun 19, 2019
Example of using the Univ. of Michigan API Directory to query the MCommunity service for a person by their uniqname.
import os
import sys
import http.client
from base64 import b64encode
import json
clientId = os.getenv('UMICH_API_DIR_CLIENT_ID')
clientSecret = os.getenv('UMICH_API_DIR_CLIENT_SECRET')
uniqname = sys.argv[1] if len(sys.argv) > 1 else os.getenv('USER')
#!/usr/bin/env python2 --
# A program I wrote for Univ. of Michigan sysadmins who are
# supporting a legacy system. They need to query various
# URLs, and get the response code and content in return.
# However, they only have an old version of curl available
# to them, one without the option to show content even when
# responses come back with an error-like HTTP status code.
# For example, a 500 code for server error may be returned
# along with content that explains the error. The old version
lsloan / v1p0p0.php
Created Apr 19, 2019
Parse hangouts.json from Google Takeout, via
View v1p0p0.php
(in this version, I added support for more message types and offer both plaintext and HTML message format)
This is a function that transforms the JSON you get from Google Takeout when you export your Hangouts history
into a PHP array which can be used to further manipulate the data.
A use case is my hangouts parser at -- a description can be seen at

perl -e '$_ = "wftedskaebjgdpjgidbsmnjgc";tr/a-z/oh, turtleneck Phrase Jar!/; print;'

lsloan / gist:bad9f599695cc35d76402453624faa38
Created Jan 18, 2019 — forked from perusio/gist:1724301
Workaround in PHP cURL for the 100-continue expectation
View gist:bad9f599695cc35d76402453624faa38
// cURL obeys the RFCs as it should. Meaning that for a HTTP/1.1 backend if the POST size is above 1024 bytes
// cURL sends a 'Expect: 100-continue' header. The server acknowledges and sends back the '100' status code.
// cuRL then sends the request body. This is proper behaviour. Nginx supports this header.
// This allows to work around servers that do not support that header.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
// We're emptying the 'Expect' header, saying to the server: please accept the body right now.
// Read here:
def find(key, dictionary):
for k, v in dictionary.items():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
for d in v:
for result in find(key, d):
View EventMediaPausedVideoMultiContextTest.php
require_once 'CaliperTestCase.php';
use IMSGlobal\Caliper\actions\Action;
use IMSGlobal\Caliper\context\Context;
use IMSGlobal\Caliper\entities\agent\Organization;
use IMSGlobal\Caliper\entities\agent\Person;
use IMSGlobal\Caliper\entities\agent\SoftwareApplication;
use IMSGlobal\Caliper\entities\lis\CourseSection;
use IMSGlobal\Caliper\entities\lis\Membership;
View caliperEventMediaPausedVideoMultiContext.json
"@context": ["", ""],
"id": "urn:uuid:956b4a02-8de0-4991-b8c5-b6eebb6b4cab",
"type": "MediaEvent",
"actor": {
"id": "",
"type": "Person"
"action": "Paused",
"object": {
lsloan /
Created Nov 1, 2018 — forked from scriptingosx/
bash functions using osascript to use some user interaction on macOS
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
consoleUser() {
python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");'
displaydialog() { # $1: message
lsloan /
Created Oct 5, 2018 — forked from ericlathrop/
Convert MH mail folders to MBOX files, which are used by Mozilla Thunderbird.
# By Eric Lathrop <>
# Convert MH mail folders to MBOX files
# Useful for switching to Mozilla Thunderbird
# Copy this script to ~/Mail/ and execute.
You can’t perform that action at this time.