Skip to content

Instantly share code, notes, and snippets.

View 4np's full-sized avatar

uǝoɹǝſ 4np

  • The Netherlands
View GitHub Profile
@4np
4np / keep-admin-membership-cronjob.txt
Created June 29, 2026 13:12
Stay part of the macOS / Active Directory admin group.
# Add this cronjob for root (e.g. see sudo crontab -l) and replace user.name with the actual username
# of the user that should retain admin membership). Whenever the admin membership is revoked the the
# user, this cronjob will re-add the user to the admin group.
#
# This runs every second; tweak the trigger moment if needed.
* * * * * dscl . -read /Groups/admin GroupMembership|grep -vq "user.name" && dscl . -merge /Groups/admin GroupMembership "user.name"
@4np
4np / install_steam.sh
Last active June 28, 2026 10:35
Install Steam on macOS without installing Rosetta 2
#!/bin/bash
#
# The Steam Installer requires Rosetta 2, while the Steam app itself is a universal binary.
# This script will download Steam from Valve's CDN and install it directly, bypassing the
# installer's Rosetta 2 requirement.
#
# This script is an adaptation of https://github.com/i1rr/steam-arm64-mac, and differs in
# several security-focused ways:
# 1) Verifies authenticity before installation. It validates the downloaded Steam.app's
# Apple code signature and confirms the Valve Team ID (MXGJJ98X76) before copying
@4np
4np / touch-id-to-sudo.md
Created November 4, 2024 08:28
Use Touch ID or Apple Watch to sudo or authorize other Administrator tasks.

sudo using Touch ID or Apple Watch double press

It is possible to enable Touch ID to authorize sudo and other administrative tasks. If you have linked an Apple Watch you'll also be able to double press the Apple watch side button to approve.

You need to do the following in terminal:

cd /etc/pam.d/
sudo cp sudo_local.template sudo_local
@4np
4np / LocalizedTests.swift
Created August 1, 2024 16:15
Run tests using a particular locale and / or language (useful for SPM projects)
import XCTest
class SomeTests: XCTestCase {
override class func setUp() {
super.setUp()
UserDefaults.standard.set("en_US", forKey: "AppleLocale")
UserDefaults.standard.set(["en_US"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
}
@4np
4np / WireGuard iOS HOWTO.md
Last active March 30, 2026 05:08
Setting up WireGuard to secure iPhone traffic

WireGuard

How to set up WireGuard as an iOS VPN configuration in order to tunnel all traffic from an iOS or iPadOS device through a Linux server.

While there are many configurations possible, my intentation was to secure the traffic from my iOS device by routing it securely through a Linux server. As such, this HowTo will show you how to set-up an initial working configuration, which you can customize afterward.

Most likely things will be missing, such as how to configure the firewall or the init scripts on your Linux distribution. As it won't be possible to cover all Linux flavors this HowTo will attempt to give you a working WireGuard configuration, leaving it up to you to fill-in the blanks. Feel free to write a comment to touch upon your specific situation to help others that might stumble upon this HowTo :)

Note: In these configuration examples I use 10.8.0.1/24 and 10.8.0.2/24. However, as WireGuard IPs may not overlap your other network interfaces

@4np
4np / Podfile
Created July 28, 2022 09:54
Podfile with customized Xcode sandbox sync messages if the sandbox is not in sync with Podfile.lock
source 'https://cdn.cocoapods.org/'
platform :ios, '15.0'
inhibit_all_warnings!
use_frameworks!
target 'MyApp' do
pod 'SomePod', '~> 1.0'
end
@4np
4np / Netherlands-Corona-Check-Info.sh
Last active July 28, 2022 09:56
Netherlands Corona Check Info
# Configuration
curl -s https://verifier-api.coronacheck.nl/v4/verifier/config | jq -r .payload | base64 -d | jq .
# Public keys
curl -s https://verifier-api.coronacheck.nl/v4/verifier/public_keys | jq -r .payload | base64 -d | jq .
@4np
4np / remove-ios-simulators.sh
Created December 9, 2021 11:16
Remove all installed iOS Simulators
rm -rf ~/Library/*/CoreSimulator
@4np
4np / macOS-beta-enrollment.md
Last active November 23, 2020 13:16
Fix macOS beta opt out / unenrollment

Sometimes unenrolling from the macOS beta feed does not work properly.

macOS Beta Channel

You can fix this by enrolling / unenrolling through Terminal:

sudo /System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil enroll DeveloperSeed
sudo /System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil unenroll
@4np
4np / RetainCyclePlayground.swift
Last active May 15, 2020 08:21
A Swift Playground demonstrating why you need to again weekly capture self in nested closures after unwrapping self.
import Cocoa
class TestClass {
var name = ""
var block1: (() -> Void)?
var block2: (() -> Void)?
var retainCount: Int {
CFGetRetainCount(self)
}