Skip to content

Instantly share code, notes, and snippets.

@davedelong
davedelong / DarkMode.applescript
Last active September 10, 2022 04:40
Toggle Dark Mode
on setDarkMode(shouldBeDark)
set paneID to "com.apple.preference.general"
tell application "System Events"
if dark mode of appearance preferences is shouldBeDark then return
end tell
set paneWasOpen to false
@ole
ole / Mojave-dynamic-wallpaper-notes.md
Last active November 3, 2024 20:05
Reverse-engineering the dynamic wallpaper file format in macOS Mojave.

The dynamic wallpaper in MacOS Mojave is a single 114 MB .heic file that seems to contain 16 embedded images.

It also contains the following binary plist data in its metadata under the key "Solar". It's an array of 16 items, each with four keys:

  • i (integer). This seems to be the image index.
  • o (integer). This is always 1 or 0. Stephen Radford thinks it indicates dark mode (0) vs. light mode (1).
  • a (decimal). I’m pretty sure this is the angle of the sun over the horizon. 0º = sunset/sunrise. 90º = sun directly overhead. Negative values = sun below horizon.
  • z (decimal). This seems to be the cardinal position of the sun relative to the camera. 0º = sun is directly in front of the camera. 90º = sun is directly to the right of the camera. 180º = sun is directly behind the camera.
@timsutton
timsutton / mv1Password.sh
Created May 27, 2018 19:52
1P 'mv1Password' script
#!/bin/sh
# this script removes the binary before we install it to ensure that we don't end up with a hybrid of what was there and what we're installing
echo "Removing legacy helper startup items"
loggedInUser=$(stat -f%Su /dev/console)
bundleIds=( "2BUA8C4S2C.com.agilebits.onepassword4-helper"
"2BUA8C4S2C.com.agilebits.onepassword-osx-helper"
"com.agilebits.onepassword-osx-helper"
"ws.agile.1PasswordAgent"
@gopsmith
gopsmith / disable.sh
Last active July 22, 2024 20:35
Disable bunch of #$!@ in High Sierra
#!/bin/bash
# NOTE: This script must be run from Terminal within RECOVERY MODE. This version is for macOS High Sierra.
# There is no need to disable SIP (via csrutil), because recovery mode is not constrained by SIP.
# WARNING: It might enable things that you may not like. Please double check the services in the TODISABLE vars.
#
# For OSes newer than High Sierra, see comments in the original gist author's Catalina version, at
# https://gist.github.com/pwnsdx/1217727ca57de2dd2a372afdd7a0fc21
# (see the "Note about Big Sur" at the top, and there are comments about Monterey further down).
#
@mohanpedala
mohanpedala / python_pip_ssl_issue.md
Last active April 29, 2019 18:05
python pip ssl issue while installing requirements and boto3 installation for python3
  • You can ignore SSL errors by setting pypi.org and files.pythonhosted.org as trusted hosts.
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>

Note: Sometime during April 2018, the Python Package Index was migrated from pypi.python.org to pypi.org. This means "trusted-host" commands using the old domain no longer work.

  • Permanent Fix: You may want to add the trusted hosts and proxy to your config file.
mkdir -p ~/.config/pip
@deyixtan
deyixtan / sublime_text_patch.md
Last active July 26, 2024 10:35
Sublime Text Patching Guide

Automated Patching

Download slt.py python script (supports multiple build) from this repository.

Usage

python slt.py <"sublime_text file path">


Manual Patching

#!/usr/bin/env pwsh
# ./move-ios-media.ps1 '/Users/hudgeo/Desktop/camera'
# ./move-ios-media.ps1 '/Users/hudgeo/Desktop/camera', '/Users/hudgeo/Desktop/iGeoffCamera'
param( [Parameter(Mandatory=$true)] [string[]] $directories )
Write-Host "Using Powershell $($PSVersionTable.PSEdition) v $($PSVersionTable.PSVersion)"
$logFile = "$HOME/Scripts/move-ios-media.txt"
$picsRoot = "$HOME/Pictures/By Year"; $vidRoot = "$HOME/Movies/By Year"
$preview = $false; $autoOpenPathFinder = $true
@fryfrog
fryfrog / radarr_cleanup_packed_torrent.sh
Last active March 29, 2023 17:21
A Radarr post processing script to remove the video file from packed torrents, modified version of subzero79/87a347a07964390884c9
#!/bin/bash
# Examples for testing
# radarr_moviefile_sourcefolder="/data/torrent/movies/Justice.League.2017.1080p.HDRip.X264.AAC-m2g" radarr_moviefile_sourcepath="/data/torrent/movies/Justice.League.2017.1080p.HDRip.X264.AAC-m2g/Justice.League.2017.1080p.HDRip.X264.AAC-m2g.mkv"
# Instructions
# Put this script somewhere on your file system like /usr/local/bin and make it executable.
#
# In Radarr, Settings -> Connect add a Custom Script
# On Grab: No
#! /bin/bash
# =====================================================
# * macOS Maintenance Script *
# * Written by Kristan M. Kenney (iCeFuSiOn) *
# * Modified by Mike Wilkie (github.com/MikeWilkie) *
# * Last modified on May 1, 2018 06:05:18 PM EST *
# * Revision 1.0.1c *
# * For use on macOS 10.13 High Sierra Only! *
# * I AM NOT RESPONSIBLE IF YOU DO SOMETHING WRONG! *
@slowkow
slowkow / take-screenshot.scpt
Last active September 29, 2019 01:04
Applescript to take a screenshot with the application title in the filename.
-- take-screenshot.scpt
-- Kamil Slowikowski
-- 2019-09-28
-- Get the title of the frontmost application window.
-- https://stackoverflow.com/questions/5292204
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true