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
View GitHub Profile
@lsloan
lsloan / v1p0p0.php
Created Apr 19, 2019
Parse hangouts.json from Google Takeout, via https://paste.jay2k1.com/view/5fcebdfe
View v1p0p0.php
<?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 http://hangoutparser.jay2k1.com/ -- a description can be seen at
http://blog.jay2k1.com/2014/11/10/how-to-export-and-backup-your-google-hangouts-chat-history/
View JAPH.md

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

@lsloan
lsloan / gist:bad9f599695cc35d76402453624faa38
Created Jan 18, 2019 — forked from perusio/gist:1724301
Workaround in PHP cURL for the 100-continue expectation
View gist:bad9f599695cc35d76402453624faa38
<?php
// 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: http://pilif.github.com/2007/02/the-return-of-except-100-continue/
View dictionaryKeyFind.py
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
<?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": ["https://some.domain.com/caliper/ctx/v1p1", "http://purl.imsglobal.org/ctx/caliper/v1p1"],
"id": "urn:uuid:956b4a02-8de0-4991-b8c5-b6eebb6b4cab",
"type": "MediaEvent",
"actor": {
"id": "https://example.edu/users/554433",
"type": "Person"
},
"action": "Paused",
"object": {
@lsloan
lsloan / bashdisplay.sh
Created Nov 1, 2018 — forked from scriptingosx/bashdisplay.sh
bash functions using osascript to use some user interaction on macOS
View bashdisplay.sh
#!/bin/bash
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
message=${1:-"Message"}
@lsloan
lsloan / mh2mbox.sh
Created Oct 5, 2018 — forked from ericlathrop/mh2mbox.sh
Convert MH mail folders to MBOX files, which are used by Mozilla Thunderbird.
View mh2mbox.sh
#!/bin/bash
#
# mh2mbox.sh
# By Eric Lathrop <eric@ericlathrop.com>
#
# Convert MH mail folders to MBOX files
# Useful for switching to Mozilla Thunderbird
#
# Copy this script to ~/Mail/ and execute.
#
View openshift-pod-cleanup.sh
#!/bin/sh --
# delete pods that have a status of "Completed" or "Error"
oc get pods | tail -n +2 | awk '($3 == "Completed" || $3 == "Error") {print $1}' | xargs -I% -L1 oc delete pod/%
You can’t perform that action at this time.