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 / 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
@sloanlance
sloanlance / MediaWiki_TOC_float_right.css
Last active September 1, 2017 16:20
MediaWiki: CSS to make page tables of contents float on the right.
/* Begin https://example.org/path/to/wiki/MediaWiki:Common.js */
/* CSS placed here will be applied to all skins */
/* Simple CSS change to make page tables of contents float on the right of the page,
letting content wrap around it. To give a little separation from the content,
a wide white border is used instead of a transparent margin. The border color may
need to be changed to look good with other MediaWiki skins. */
/* Float table of contents (TOC) to the right, so text wraps around it */
/* Change thin gray border to a wide white one instead of using a transparent margin */
@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 / JSONL from MySQL.md
Last active August 2, 2017 19:12
MySQL, JSONL: An example of a MySQL query returning JSONL.
@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!)
@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}')[]'
@sloanlance
sloanlance / sortProperties.jq
Created July 12, 2017 20:40
jq: Functions to sort the *properties* of an object by key or value. I believe these are largely part of the recent versions of jq, but I think they're interesting. From the poorly-named repo https://github.com/joelpurra/jq-object-sorting (which sorts properties, not objects).
def byKeyAsc:
to_entries
| sort_by(.key)
| from_entries;
def byKeyDesc:
to_entries
| sort_by(.key)
| reverse
| from_entries;
@sloanlance
sloanlance / firstonly.sh
Created July 12, 2017 14:24
bash - firstonly.sh: A silly script to emulate `uniq` without requiring `sort` first
#!/bin/bash --
firstonly="/tmp/firstonly.${$}"
touch "${firstonly}"
while read line; do
egrep -q "^${line}\$" "${firstonly}"
if [[ ${?} -eq 1 ]]; then
# Original spacing isn't guaranteed, unfortunately.