Skip to content

Instantly share code, notes, and snippets.

View lsloan's full-sized avatar

Mr. Lance E Sloan «UMich» lsloan

  • Teaching and Learning (@tl-its-umich-edu) at University of Michigan: Information and Technology Services
  • Ann Arbor, Michigan, USA
  • 20:20 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
@lsloan
lsloan / set-dbeaver-timezone-to-UTC.txt
Created March 26, 2020 19:38 — forked from chetanppatil/set-dbeaver-timezone-to-UTC.md
Set dbeaver timezone to UTC (default timezone)
/* -------------- FOR LINUX USERS ---------------- */
1) Go to directory: "/usr/share/dbeaver"
2) Edit "dbeaver.ini" file
3) In that file add "-Duser.timezone=UTC" this line under "-vmargs" tag
4) Save it and restart dbeaver.
5) Enjoy with correct date without any date conversion.
Finally your dbeaver.ini file will look like this:
-startup

When git CLI or clients such as SourceTree fail to use the macOS (FKA Mac OS X, OSX) Keychain to store authentication credentials, it may help to set the git configuration for the credential helper. Sometimes it's necessary to rerun this configuration command at a later date even after it's been run before to set the value that may have been unset or corrupted by some other program.

The command to use is:

git config --global credential.helper osxkeychain
@lsloan
lsloan / umich_mcomm_api_query.py
Created June 19, 2019 20:44
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
lsloan / v1p0p0.php
Created April 19, 2019 15:51
Parse hangouts.json from Google Takeout, via https://paste.jay2k1.com/view/5fcebdfe
<?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/

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

@lsloan
lsloan / gist:bad9f599695cc35d76402453624faa38
Created January 18, 2019 19:05 — forked from perusio/gist:1724301
Workaround in PHP cURL for the 100-continue expectation
<?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/
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):
<?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;
{
"@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": {