Skip to content

Instantly share code, notes, and snippets.

View danielpunkass's full-sized avatar

Daniel Jalkut danielpunkass

View GitHub Profile
@douglashill
douglashill / extract-most-common-localised-strings.swift
Last active August 24, 2022 05:39
Extracts the most common translations from Apple’s glossary files. Read more: https://douglashill.co/localisation-using-apples-glossaries/
#! /usr/bin/swift
// Douglas Hill, March 2020
/*
Extracts the most common translations from Apple’s glossary files.
This script helped with localisation for KeyboardKit (https://github.com/douglashill/KeyboardKit) by leveraging Apple’s existing translations.
More detail in the article at https://douglashill.co/localisation-using-apples-glossaries/
@rmcdongit
rmcdongit / macOS_SytemPrefs.md
Last active May 4, 2024 07:49
Apple System Preferences URL Schemes

macOS 10.15 System Preference Panes

Below are a list of System Preference pane URLs and paths that can be accessed with scripting to assist users with enabling macOS security settings without having to walk them through launching System Preferences, finding panes, and scrolling to settings. Not all panes have an accessible anchor and some are OS specific.

To find the Pane ID of a specific pane, open the System Preferences app and select the desired Preference Pane. With the pane selected, open the ScriptEditor.app and run the following script to copy the current Pane ID to your clipboard and display any available anchors:

tell application "System Preferences"
	set CurrentPane to the id of the current pane
	set the clipboard to CurrentPane
@lukele
lukele / README.md
Last active August 19, 2020 22:03
Access to a keychain item's password via Security framework is lost if a user enters the wrong password once (rdar://50789571)

Summary

If a user enters the wrong password, when they are asked for their macOS user credentials to access the password of a keychain item, and press "Do not allow" when asked again, the following happens:

  • programmatic access to the keychain item's password using SecItemCopyMatching consistently fails with error OSStatus -25293, yet the user is never prompted to enter their macOS credentials

  • programmatic access to the password of any keychain item of the same keychain fails with error -25293

  • the user is not asked for their credentials again until they manually lock and unlock the login keychain (or any custom keychain the keychain item belonged to) in Keychain Access.app (or perform an action which locks and unlocks the keychain, like log out or restart of macOS)

@rnapier
rnapier / main.m
Last active April 5, 2019 17:44
GCD accessor
//
// main.m
// test
//
// Created by Rob Napier on 4/5/19.
//
#import <Foundation/Foundation.h>
@interface MyClass: NSObject
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@ddunbar
ddunbar / update-swift-dev
Created June 2, 2016 17:35
This is the script I currently use on OS X to get a working "swift-dev.xctoolchain" out of a built Swift. It isn't designed to work for anyone but me, but it should be easy to adapt. I always run this after every build, and then use `TOOLCHAINS=swift-dev swift build` (etc) to use the development compiler.
#!/bin/sh
set -e
if [ -z "${CONFIGURATION}" ]; then
CONFIGURATION=debug
fi
# Create the development toolchain.
rm -rf ~/public/swift-project/build/Ninja-ReleaseAssert/swift-dev.xctoolchain
@mattshepherd
mattshepherd / apple help book example.txt
Last active November 3, 2022 13:32
To support the table of contents button in the OS X Help Book app you need to implement the following code. This isn't documented anywhere but I found it in Apple's own help files and tested it to work. I believe it only works in the more recent versions of OS X, so you if your app supports really old versions you might want to check it.
//disable TOC button
window.HelpViewer.showTOCButton(false);
//enable TOC button
//If you call this on window load it will flash active for a brief second and then disable again.
//Call if after a delay of 250ms and is works fine
//Not sure what the second variable does yet, but passing false works fine
window.HelpViewer.showTOCButton( true, false, function() {
//do something to toggle TOC in your webpage
});
@amake
amake / lg2tmx.xsl
Last active April 26, 2022 01:31
An XSLT to convert Apple *.lg glossaries into TMX
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Convert Apple *.lg glossaries to TMX. Usage:
xsltproc [-o <output file>] [-\-stringparam srclang <source lang>] lg2tmx.xsl <input file>
If not specified, the TMX header's srclang attribute defaults to "*all*".
Get glossaries at https://developer.apple.com/downloads/?name=glossaries -->
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:param name="srclang" select="'*all*'" />
<xsl:template match="/">
<tmx version="1.4">
@mittsh
mittsh / LMWindow.m
Created September 23, 2013 10:11
How to debug your key view loop: highlights
/*
* Copyright (c) 2013 Micha Mazaheri
* Released under the MIT License: http://opensource.org/licenses/MIT
*/
#define LMWindowDEBUGResponders
#ifdef LMWindowDEBUGResponders
static BOOL _showFirstResponderOverlay = YES;
#endif
@cyberfox
cyberfox / keychain.rb
Created September 18, 2011 06:03
Convert OS X Keychain exported entries into logins for 1Password import
#!/usr/bin/env ruby
#
# Usage:
# security dump-keychain -d login.keychain > keychain_logins.txt
# # Lots of clicking 'Always Allow', or just 'Allow', until it's done...