Skip to content

Instantly share code, notes, and snippets.

@macrotis
macrotis / rmbp-screencheck.sh
Created April 7, 2014 20:13
rMBP screen manufacturer check (with fix to improve performance in extreme circumstances)
# Check for "LSN" or "LP"
# "LP" => LG screen, classic IPS, susceptible to Image Retention
# "LSN" => Samsung screen, PLS, not susceptible to Image Retention
# Anything else? Not sure about that.
# The original version began the pipeline with
#ioreg -wl0
# But recently, a gigantic dictionary got dropped in my I/O Kit registry (and I'm not sure why)
# and because the -l flag makes everything display, that was wasting a lot of CPU time.
# This version only reads the "EDID" key (hence -k EDID), greatly improving performance.
@macrotis
macrotis / calculate_mysql_dml_stats.py
Last active August 29, 2015 13:56
Reads one or more MySQL general_log files (either plaintext or gzip'd), outputs one CSV file with counts/second. Probably full of bugs, but it seems to work out so far.
#!/usr/bin/env python
from __future__ import print_function
import csv
import gzip
import itertools
import os
import re
import sys
import traceback
from datetime import datetime as dt, timedelta as td
@macrotis
macrotis / create-ssh-public-private-key-pair.sh
Last active December 16, 2015 07:39
Someone I know needed an easy way to SSH into a Linux host from a Mac without having to remember the password. The "correct" answer is to set up an RSA public/private key pair and configure the remote host to accept it, but for someone whose primary responsibilities involve wrestling with Adobe software all day, that's just another hurdle to jum…
#!/bin/bash
# The above line tells the OS to run this file with the executable stored
# in /bin/bash; in this case GNU BASH.
keydir=$HOME/.ssh/
keyfile=id_rsa
keyloc=$keydir/$keyfile
ruser= # The username of the remote user
rhost= # The IP Address or DNS name of the remote host
rport=22 # Remote port to connect to; this will nearly always be TCP 22.