Skip to content

Instantly share code, notes, and snippets.

@hafta
hafta / firefox.rcodesign
Last active November 9, 2023 21:52
Re-sign the Firefox release bundle using rcodesign and the entitlements from the mozilla-central repo. Set $MOZILLA_CENTRAL to be the path to the local clone of the mozilla-central repo.
#!/bin/bash
set -x
cp -r /Applications/Firefox.app .
find Firefox.app -type f -exec codesign --remove-signature {} \;
xattr -cr Firefox.app
cat << EOF > empty.xml
<?xml version="1.0" encoding="UTF-8"?>
@hafta
hafta / firefox.codesign
Created November 9, 2023 21:36
Re-sign the Firefox release bundle using entitlements from the mozilla-central repo. Set $MOZILLA_CENTRAL to be the path to the local clone of the mozilla-central repo and set $CSID to be the signing identity.
set -x
cp -r /Applications/Firefox.app .
find Firefox.app -type f -exec codesign --remove-signature {} \;
xattr -cr Firefox.app
codesign -v --force --sign ${CSID} --options runtime \
--entitlements ${MOZILLA_CENTRAL}/security/mac/hardenedruntime/v2/production/plugin-container.xml \
Firefox.app/Contents/MacOS/plugin-container.app
@hafta
hafta / LauncherProcessSignature.m
Last active November 7, 2023 23:08
Small debug program for printing the ProcessInfoRec launching process' signature. When macOS starts a process automatically at login due to the "Reopen windows when logging back in" checkbox, the launching process' signature is "lgnw".
#import <Foundation/Foundation.h>
#include <ApplicationServices/ApplicationServices.h>
//
// Given a single PID on the command line, print the process'
// signature and the launching process' signature. The process'
// signature is a field in the ProcessInfoRec structure.
//
// For converting the process signature 4 byte field to a string.
@hafta
hafta / macos-create-dmg-from-app.bash
Created May 2, 2022 23:32
Creates a macOS .dmg from a .app
#!/bin/bash
# Create a .dmg from the provided .app. Accepts a single argument
# which should be something like
#
# ~/mybuilds/Firefox.app
#
# Uses a 1024m disk image file. Increase as necessary.
set -x
@hafta
hafta / macos-screeninfo.py
Created February 26, 2021 21:29
Prints out the origin, dimensions, and scaling factor for each screen, indicating which is the main screen
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import sys
from AppKit import NSScreen
def print_screen(name, screen):
print("%20s: scale:%.0f at origin (%6d, %6d) with size %5d by %5d" %
@hafta
hafta / desktopImageURLForScreen.py
Created April 22, 2020 04:51
Python script to print the path to the image used as the desktop background of the focussed screen
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. */
from AppKit import NSScreen, NSWorkspace
def main():
focussedScreen = NSScreen.mainScreen()
if not focussedScreen:
@hafta
hafta / .hgrc
Last active February 20, 2020 02:07
Mercurial work flow config
[extensions]
histedit =
rebase =
strip =
[alias]
down = up -r "p1(p1())"
outpg = log -G -r outp --color=always --template allfiles
[revsetalias]
outp = parents(outgoing())|outgoing()
[templates]
@hafta
hafta / gist:bca83004cdf7542dbf71b46e629ec0af
Created January 24, 2020 18:36
Mac python code to check if a given process is sandboxed.
#!/usr/bin/python
import argparse
import ctypes
import errno
import os
import sys
SUCCESS_EXIT_CODE = 0
ERROR_EXIT_CODE = 1