Skip to content

Instantly share code, notes, and snippets.

View sloanlance's full-sized avatar
Certified GitHub Pro

Mr. Lance E Sloan sloanlance

Certified GitHub Pro
View GitHub Profile
@sloanlance
sloanlance / PHP Timezone Constants
Last active October 27, 2017 16:01
#PHP – A note I added to the PHP manual about timezone constants. http://php.net/manual/en/function.date-default-timezone-set.php#121800
date_default_timezone_set(DateTimeZone::listIdentifiers(DateTimeZone::UTC)[0]);
@sloanlance
sloanlance / power.sh
Created September 26, 2017 22:26 — forked from lsloan/power.sh
When "sudo -s" just isn't enough, you need more power.
sudo /bin/env bash
@lsloan
lsloan / power.sh
Created September 26, 2017 22:25
When "sudo -s" just isn't enough, you need more power.
sudo /bin/env bash
@sloanlance
sloanlance / MediaWiki_hide_TOC.js
Last active September 1, 2017 16:23
MediaWiki: Hide pages' tables of contents upon loading.
/* Begin https://example.org/path/to/wiki/MediaWiki:Common.js */
/* Any JavaScript here will be loaded for all users on every page load. */
/* This file will be included in response to requests like https://example.org/path/to/wiki/index.php?action=raw&smaxage=0&gen=js */
/* Hide the table of contents each time any page is loaded. */
function hideToc() {
try {
// Detect whether the page's TOC is displayed.
if (document.getElementById('toc').getElementsByTagName('ul')[0].style.display != 'none') {

Depersonalize JSON

Why

If JSON data is to be shared for analysis, it's often necessary to depersonalize the data first. Depersonalization is different than anonymization. If data is anonymized, all information about the user is removed. Depersonalization, however, changes the user information to values that can't be recognized as being related to the real user. This way, it's still possible to see relationships within the data.

@sloanlance
sloanlance / Silence (250ms).mp3
Last active July 21, 2017 19:16
250ms of silence in an MP3 file. This makes an excellent ringtone for a contact on phones that can't block specific callers. (Thanks for nothing, TracFone!)
@lsloan
lsloan / jsonlSort.sh
Created July 13, 2017 17:47 — forked from sloanlance/jsonlSort.sh
jq, JSON: Sort JSONL by using jq's `--slurp` option to treat it as a JSON array
#!/bin/sh --
# Execute with an argument containing the name of the property to be
# used for sorting.
# Improved according to a suggestion from @pkoppstein in response to my
# support issue:
# https://github.com/stedolan/jq/issues/1447#issuecomment-314918635
jq --slurp --compact-output 'sort_by(.'${1}')[]'

Editing remote files in Vim with SSH

  1. Configure SSH

    In ~/.ssh/config, include the lines:

    Host *
    ControlPath ~/.ssh/sockets/%r@%h-%p
    
@sloanlance
sloanlance / Editing remote files in Vim with SSH.md
Created July 13, 2017 16:11
Editing remote files in Vim with SSH

Editing remote files in Vim with SSH

  1. Configure SSH

    In ~/.ssh/config, include the lines:

    Host *
    ControlPath ~/.ssh/sockets/%r@%h-%p
    
@sloanlance
sloanlance / jsonlSort.sh
Last active July 13, 2017 18:01
jq, JSONL: Use jq's `--slurp` option to treat JSONL as a JSON array, then sort it
#!/bin/sh --
# Execute with an argument containing the name of the property to be
# used for sorting.
# Improved according to a suggestion from @pkoppstein in response to my
# support issue:
# https://github.com/stedolan/jq/issues/1447#issuecomment-314918635
jq --slurp --compact-output 'sort_by(.'${1}')[]'