Skip to content

Instantly share code, notes, and snippets.

View n8felton's full-sized avatar
🍎

Nate Felton n8felton

🍎
View GitHub Profile
@grihabor
grihabor / Makefile.version
Last active April 22, 2025 15:01
Makefile to use for incremental semantic versioning
MAKE := make --no-print-directory
DESCRIBE := $(shell git describe --match "v*" --always --tags)
DESCRIBE_PARTS := $(subst -, ,$(DESCRIBE))
VERSION_TAG := $(word 1,$(DESCRIBE_PARTS))
COMMITS_SINCE_TAG := $(word 2,$(DESCRIBE_PARTS))
VERSION := $(subst v,,$(VERSION_TAG))
VERSION_PARTS := $(subst ., ,$(VERSION))
@JackGruber
JackGruber / Get-ProcessOutput.ps1
Created May 11, 2018 17:12
Execute a process and return the output from standard output and standard error
function Get-ProcessOutput
{
Param (
[Parameter(Mandatory=$true)]$FileName,
$Args
)
$process = New-Object System.Diagnostics.Process
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.RedirectStandardOutput = $true
@bruienne
bruienne / find32bit.py
Created January 25, 2018 17:08
Find 32-bit executables in a given path. Uses the macholib module that ships with macOS.
#!/usr/bin/python
from macholib import MachO
import macholib
import os
import sys
path = sys.argv[1]
for root, dirs, files in os.walk(path):
@erikng
erikng / 32bitapps.py
Last active April 16, 2018 11:46
32bitapps.py
#!/usr/bin/python
import subprocess
import plistlib
cmd = ['/usr/sbin/system_profiler', '-xml', 'SPApplicationsDataType']
proc = subprocess.Popen(cmd, shell=False, bufsize=-1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = proc.communicate()
plist = plistlib.readPlistFromString(output)
items = plist[0]['_items']
for item in sorted(items, key=lambda x: x.get('path')):
@jakeashcraft
jakeashcraft / postman-pre-script-oauth2.js
Last active November 30, 2022 08:53
Postman Pre-request Script used to automatically retrieve a new OAuth2 token when the token is expired
pm.expect(pm.globals.has('accessToken')).to.be.true;
const sdk = require('postman-collection');
const JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
const currentToken = pm.globals.get('accessToken').replace('Bearer ', '');
const path = pm.environment.get('url') + '/auth/token';
let expired = true;
if(currentToken && currentToken.length > 0) {
@masklinn
masklinn / cheatsheet.md
Last active June 30, 2025 01:17
launchctl/launchd cheat sheet

I've never had great understanding of launchctl but the deprecation of the old commands with launchctl 2 (10.10) has been terrible as all resources only cover the old commands, and documentation for Apple utilities is generally disgracefully bad, with launchctl not dissembling.

Mad props to https://babodee.wordpress.com/2016/04/09/launchctl-2-0-syntax/ which contains most details

domains

Internally, launchd has several domains, but launchctl 1 would only ask for service names,

@shr00mie
shr00mie / letsencrypt_esxi.sh
Last active June 13, 2024 22:32
Let's Encrypt SSL for ESXi
#!/bin/bash
#
## -----------------------------=[ WARNING ]=-------------------------------- ##
#
# This script is now woefully out of date due to which accounts ESXi allows to
# ssh into the box as well as sticky folders/file flags.
# I've since ported the whole thing to python with a lot of bells and whistles
# and if i get around to making it public, i'll put a link here.
#
## -------------------------------=[ Info ]=--------------------------------- ##
@carlashley
carlashley / darwin_env_var.sh
Last active March 30, 2023 17:07
Darwin Environment Variables
#!/bin/sh
# User path
/usr/bin/getconf DARWIN_USER_DIR
# Temp directory
# Note - $TMPDIR is the same as this
/usr/bin/getconf DARWIN_USER_TEMP_DIR
# Cache directory
@gregneagle
gregneagle / fancy_defaults_read.py
Last active December 5, 2024 10:38
fancy_defaults_read.py: Reads a preference, prints its value, type, and where it is defined.
#!/usr/bin/python
import os
import sys
from CoreFoundation import (CFPreferencesAppValueIsForced,
CFPreferencesCopyAppValue,
CFPreferencesCopyValue,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost,
#!/usr/bin/python
# encoding: utf8
#
# Portions of code re-used from "makecatalogs" by Greg Neagle
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Yo may obtain a copy of hte License at
#
# https://www.apache.org/licenses/LICENSE-2.0