Skip to content

Instantly share code, notes, and snippets.

View andrewp-as-is's full-sized avatar
🔍

Andrew P andrewp-as-is

🔍
View GitHub Profile
@andrewp-as-is
andrewp-as-is / lsappinfo.sh
Last active April 1, 2024 15:57
macOS app frontmost
#!/usr/bin/env bash
{ set +x; } 2>/dev/null
lsappinfo info -only name `lsappinfo front` | awk -F'"' '{print $4}'
lsappinfo info -only pid `lsappinfo front` | awk -F'"=' '{print $2}'
lsappinfo info -only bundlepath `lsappinfo front` | awk -F'"' '{print $4}'
lsappinfo info -only bundleID `lsappinfo front` | awk -F'"' '{print $4}'
@andrewp-as-is
andrewp-as-is / macOS-list-ports.sh
Last active March 18, 2024 19:14
macOS list ports #macos
#!/usr/bin/env bash
PORT=8013
lsof -nP -iTCP:$PORT | grep LISTEN;:
@andrewp-as-is
andrewp-as-is / Dock add app.sh
Last active February 27, 2024 20:13
macOS Dock scripts
#!/usr/bin/env bash
path=/Applications/Automator.app
defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>$path</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"; killall Dock
@andrewp-as-is
andrewp-as-is / Launchctl_Unload-10.14.sh
Created August 1, 2023 12:41 — forked from mmillar-bolis/Launchctl_Unload-10.14.sh
A Quick Little Script to Force Disable Certain LaunchDaemons in macOS
#!/bin/bash
# I have managed to map out some undesirable daemons and agents. Most of these
# can be disabled without too much consequence.
## Daemons
# com.apple.analyticsd - Anonymized application analytics daemon
# com.apple.appleseed.fbahelperd - Feedback Assistant Helper Daemon
# com.apple.awacsd - Apple Wide Area Connectivity Service Daemon
# com.apple.backupd - Apple TimeMachine service
@andrewp-as-is
andrewp-as-is / Time Machine exclusions.command
Last active February 10, 2024 08:23
macOS Time Machine exclusions
#!/usr/bin/env bash
{ set +x; } 2>/dev/null
IFS=$'\n'
set "$@" $(find ~ -name ".*" ! -name ".CFUserTextEncoding" ! -type l -mindepth 1 -maxdepth 1) # dotfiles
set "$@" $(find ~ -name "Google *" -mindepth 1 -maxdepth 1) # Google Drive
set "$@" ~/git # store on github/etc :)
set "$@" ~/node_modules
set "$@" ~/Applications # install apps with brew cask
@andrewp-as-is
andrewp-as-is / Dockerfile
Created January 16, 2024 08:18
Docker alpine pycurl
FROM python:3.7-alpine
RUN apk add --no-cache libcurl
ENV PYCURL_SSL_LIBRARY=openssl
RUN apk add --no-cache --virtual .build-deps build-base curl-dev \
&& pip install pycurl \
&& apk del --no-cache --purge .build-deps \
&& rm -rf /var/cache/apk/*
@andrewp-as-is
andrewp-as-is / python remove emoji.py
Last active September 21, 2023 05:28
emoji remove
#!/usr/bin/env python
import re
s = 'word1 :blush: word2'
print(re.sub(':[^:]+:', '', s).strip())
text body
@andrewp-as-is
andrewp-as-is / sysctl.sh
Last active June 16, 2023 11:48
macOS Time Machine speed up #macos #sysctl
#!/usr/bin/env bash
# speed up Time Machine backup, Mac App Store install, etc
sudo /usr/sbin/sysctl debug.lowpri_throttle_enabled=0
# restore defaults
sudo /usr/sbin/sysctl debug.lowpri_throttle_enabled=1
# check:
sysctl debug.lowpri_throttle_enabled
@andrewp-as-is
andrewp-as-is / defaults.sh
Last active February 24, 2023 17:58
macOS security
#!/usr/bin/env bash
# Disable Face Detect in Photos app
defaults write com.apple.iPhoto PKFaceDetectionEnabled 0
defaults write com.apple.gamed Disabled -bool true
defaults write com.apple.NetworkBrowser DisableAirDrop -bool YES # log out, log in