Skip to content

Instantly share code, notes, and snippets.

View rsperl's full-sized avatar

Richard rsperl

  • North Carolina, United States
View GitHub Profile
@rsperl
rsperl / tcpdump_cheatsheet.sh
Last active July 25, 2022 14:56
tcpdump cheatsheet #snippet
#!/bin/bash
# -n don't resolve IP
# -l buffer by line (show output without buffering)
# -v slightly verbose
# show connections to remote port 3306
# shows when connections are made to a database
tcpdump -nlv port 3306
@rsperl
rsperl / mmctl.sh
Last active July 25, 2022 14:25
make mattermost stay running with a plist and launchctl #snippet
#!/bin/bash
# adapted from http://hints.macworld.com/article.php?story=20110617204111325
set -e
label="mattermost"
plistfile="$HOME/Library/LaunchAgents/$label.plist"
function setup_mattermost() {
@rsperl
rsperl / vscode-update.sh
Last active July 25, 2022 15:22
upgrade vscode from the command line #snippet
#!/bin/bash
set -e
URL="https://go.microsoft.com/fwlink/?LinkId=723966"
APP_DIR="$HOME/Dev"
BACKUP_APP="$APP_DIR/previous_vscode.bak"
CURRENT_APP="$APP_DIR/Visual Studio Code - Insiders.app"
# get the url for latest download and parse out hash
download_url=$(curl --silent -LI "$URL" | grep Location | grep insider.zip | awk '{print $2}' | sed -e 's/\r//')
@rsperl
rsperl / .gitignore
Last active July 25, 2022 14:59
transpose rows of data to one field per line #snippet
.gitignore
.gistinfo.json
@rsperl
rsperl / .gitignore
Last active July 25, 2022 15:00
shwartzian transform to sort list without temporary arrays #snippet
.gitignore
.gistinfo.json
@rsperl
rsperl / .gitignore
Last active July 25, 2022 15:02
countdown days left to a future date in bash #snippet
.gitignore
.gistinfo.json
@rsperl
rsperl / .gitignore
Last active July 25, 2022 15:02
monitor percent cpu for a given process #snippet
.gistinfo.json
@rsperl
rsperl / README.md
Last active July 25, 2022 15:03 — forked from steve-jansen/README.md
Stop and start Symantec Endpoint Protection on OS X #nosnippet

This script enables you stop and start Symantec Endpoint Protection on OS X

Installation

sudo curl https://gist.githubusercontent.com/steve-jansen/61a189b6ab961a517f68/raw/sep -o /usr/local/bin/sep
sudo chmod 755 /usr/local/bin/sep
sudo chown root:staff /usr/local/bin/sep
@rsperl
rsperl / pubsub_decorators.py
Last active July 25, 2022 15:03
pubsub with decorators in python #snippet
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import inspect
from functools import wraps
class Handler1(object):
def handle_hello(self, f):
@wraps(f)
def decorated(self, *args, **kwargs):
print("handler1: handle_hello")
@rsperl
rsperl / subprocess_example.py
Last active July 25, 2022 15:04
use subprocess to run external process and capture stdout, stderr, and the return code #snippet
#!/usr/bin/env python3
import subprocess
p = subprocess.run(
["echo", "hello"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5
)
print(f"return code: {p.returncode}")
print(f"stdout: {p.stdout.decode().strip()}")
print(f"stderr: {p.stderr.decode().strip()}")