Skip to content

Instantly share code, notes, and snippets.

View Frick's full-sized avatar

Michael Frick Frick

  • MongoDB
  • Raleigh, NC
View GitHub Profile
@Frick
Frick / logsort.py
Last active November 8, 2019 05:00
Well this got out of hand quickly...
#!/usr/bin/env python3
"""
Minimally parse logs in order to merge their contents in sorted order with minimal
resource usage - primarily memory, in order to support very large log files. For
example, whether 10 MBs or 10 GBs of logs, <15 MBs of memory is typically allocated.
Assumes each individual log file is already sorted.
The bash 'globstar' option is recommended in order to easily pass all log paths like:
./logsort.py mongodb-*/**/*.log
To enable:
@Frick
Frick / keybase.md
Created July 18, 2016 15:12
Keybase proof

Keybase proof

I hereby claim:

  • I am frick on github.
  • I am mdfrick (https://keybase.io/mdfrick) on keybase.
  • I have a public key ASBnGcBSPaed__zc5v_ojFlruHUR53xyZcx-Jff-P-02pwo

To claim this, I am signing this object:

@Frick
Frick / fixssh.sh
Last active April 9, 2019 14:48
Quick way of fixing host SSH changes without flat out disabling StrictHostKeyChecking
function fixssh {
local hostname=""
local ip=""
for arg in $@; do
local hostout=$(host "$arg" 2>/dev/null)
if [ $? -eq 0 ]; then
local out=$(echo "$hostout" | grep -o "has address .*$" | grep -Eo "[0-9.]{7,15}")
if [ $? -eq 0 ]; then
local hostname="$arg"
local ip="$out"
@Frick
Frick / listening.sh
Last active May 29, 2022 14:11
A function I keep in my .bashrc for quickly determining what processes are listening on what ports, protocols and interfaces - sorted by port number.
function listening {
if [ "${1}" = "-h" ]; then
echo "Usage: listening [t|tcp|u|udp] [ps regex]"
return
fi
DISP="both"
NSOPTS="tu"
if [ "${1}" = "t" -o "${1}" = "tcp" ]; then
DISP="tcp"
NSOPTS="t"
@Frick
Frick / openfiles.sh
Last active July 29, 2020 06:28
A function I keep in my .bashrc for quickly finding what files a process has open.
function openfiles {
if [ "${1}" = "-h" ]; then
echo -e "Usage: openfiles [r|w|m|R|W] regex\n -r opened for reading or read/write\n -w opened for writing or read/write\n -m accessed from memory (includes running command)\n -R opened for reading only\n -W opened for writing only"
return
fi
if [ "$#" = "0" ]; then
echo "Process signature/regex required."
return
fi
MODE="(w|u)"
@Frick
Frick / timestamp2date.sh
Last active July 29, 2020 06:26
This is a quick Linux shell script which, when bound to a keyboard shortcut, allows you to highlight a Unix timestamp (seconds, milliseconds, microseconds, hex) or a MongoDB ObjectID [double clicking to highlight/select works great here], mash your keyboard shortcut and see a popup of the date/time in your specified format. It also copies it to …
#!/bin/bash
DATE_FORMAT="%F %T %Z"
SEL=$(xclip -o | sed 's/[^0-9A-Fa-f]//g')
notify () {
# hack to allow more than one alert to be sent every 6 seconds
pkill -9 -f "notify-osd"
notify-send -i appointment-new "$1"
}