Skip to content

Instantly share code, notes, and snippets.

View jerrykrinock's full-sized avatar

Jerry Krinock jerrykrinock

View GitHub Profile
@jerrykrinock
jerrykrinock / gist:82bf441bdd1ab78cbe769d8158b4df0f
Created January 26, 2021 03:44
How to replace deprecated CFURLCreateStringByAddingPercentEscapes() with -[NSString stringByAddingPercentEncodingWithAllowedCharacters:]
Question: Which NSCharacterSet should I pass to -[NSString stringByAddingPercentEncodingWithAllowedCharacters:]
so that it works exactly like the deprecated CFURLCreateStringByAddingPercentEscapes() did?
Answer: Either URLFragmentAllowedCharacterSet or URLQueryAllowedCharacterSet
Explanation:
That answer comes from the following program output, which is the result of running
the code below it.
Frag Host Pswd Path Qery User CFnd
@jerrykrinock
jerrykrinock / PackageExtensions.sh
Last active August 22, 2017 00:06
Script which packages browser extensions for Firefox, Opera and Chrome
packExtensionForBrowser () {
echo "#"
echo "##### Building $productName as $type for $browser #####"
cd $sourceDir
# Remove .DS_Store file, if any
rm -f $productName/BrowserCommon.DS*
# Make a temporary directory path which we shall use for building
@jerrykrinock
jerrykrinock / JerryLib.scptd
Last active March 21, 2023 11:52
My personal utility library of AppleScript handlers, and some one-liners
-- To load this library, see section titled "-- Using a handler in a .scpt library" at the top of One_Liners.scpt.
on testJerryLib()
return 0
end testJerryLib
(* The bad thing about this handler is that it always asks the user for admin credentials whether or not they are actually needed to answer the question on the given path.
Obviously, you can remove the 'with adminstrator privileges'. Unfortunately, this will cause the method to return 'false' if an existing path cannot be probed because of bad permissions. I can't see any way to differentiate between inadequate permissions and nonexisting file because they both set errNumber = 54.
The -e checks for directories or files. To require that the given path be a directory, use -d. For file, use -f. For more variations, see:
http://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html *)
@jerrykrinock
jerrykrinock / SSYTroubleZipper
Last active July 4, 2018 21:33
Demonstrates a boatload of AppleScript techniques, primarily focused on gathering data from a user's Mac account for troubleshooting.
(* Actually running this script requires that several other tools be included into
the script's package. The entire package, which should include the latest version of
this script, may be downloaded from here:
http://sheepsystems.com/files/SSYTroubleZipper.zip *)
property scriptVersion : "0255 published 2014-12-04"
property companyUTI : "com.sheepsystems"
property ourProcessNames : {"Bookdog", "Bookwatchdog", "BookMacster", "Markster", "Smarky", "Synkmark", "Sheep-Sys-Worker", "Sheep-Sys-Quatch", "Sheep-Sys-Thomas", "Sheep-Sys-UrlHandler", "FileAliasWorker"}
-- The above are all acted upon in 'try' blocks, so it's OK if some don't exist in certain context(s).
property companyName : "Sheep Systems"
@jerrykrinock
jerrykrinock / Finale Save as PDF.applescript
Last active September 7, 2020 03:37
Saves the current Finale music score as a PDF file, named and located, overwriting old PDF, with one keystroke
-- Version: Substantially rewrote on 2020 09 06 to use Graphics > Export Pages instead of
File > Print > Save as PDF. Also now works with Finale 26 and macOS 10.11 Big Sur (Beta 6).
Have not tested with earlier versions.
--------------------------------------------------
-- Begin Parameters which you should edit
--------------------------------------------------
-- Set saveDirPath to the path to the directory you always save your PDF outputs saved to.
-- Possibly starting with OS X 10.10.2, the "~" in the following no longer expands to your home folder. Path must start with /Users/<yourShortName>
@jerrykrinock
jerrykrinock / YaBBCullDeadbeatMembers.pl
Last active August 29, 2015 14:04
In a YaBB Forum (http://www.yabbforum.com), removes deadbeat members created by spamming attempts
#!/usr/bin/perl
=com
This script takes one parameter, the path/to/Members subdirectory of a YaBB 2.4 directory. It deletes files of any members who have registered more than 72 hours ago, and have never posted any posts that have not been removed. Presumably such members were registered by spammers' robots.
It also modifies the 'memberlist.txt' and 'memberinfo.txt' files in there appropriately, deleting the culled members. It does not touch the 'memberlist.inactive', which appears to be records of "new members who have not yet registered".
This script has been tested in Mac OS X and should work in any Unix system.
@jerrykrinock
jerrykrinock / codesigndeveloperid.pl
Last active August 25, 2018 19:04
Signs (codesign) with Developer ID, and zips an OS X app, recursively, from the inside out. When I wrote this script, Apple's `codesign` tool did not do the recursion and therefore did not work. Maybe today it does. Try Apple's tool before using this. This is handy for sending AppleScripts (in the form of OS X apps) to individual users who need …
#!/usr/bin/perl
use strict ;
use IPC::Run ;
use File::Basename ;
use File::Util ;
# Sometimes this is necessary for modules in this directory to be found at compile time when running on my Mac:
use lib '/Users/jk/Documents/Programming/Scripts' ;
@jerrykrinock
jerrykrinock / CheckAndClearXattrs.plist
Last active January 6, 2019 00:20
CheckAndClearXattrs.sh checks a given target directory for extended attributes. If any extended attributes are found, it removes them and displays a dialog. Otherwise, it just logs to the system console. You provide the target directory's path as the first and only argument to this script. I launchd it once an hour, using the file, CheckBuildDir…
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>CheckBuildDirXattrs</string>
<key>ProgramArguments</key>
<array>
<string>/Users/jk/bin/CheckAndClearXattrs.sh</string>
<string>/Users/jk/Documents/Programming/Builds</string>
@jerrykrinock
jerrykrinock / SSYShipProduct.pl
Last active July 4, 2018 21:49
This script is for shipping OS X apps outside the Mac App Store. It will run you through a comprehensive quality-control checklist, supports alpha, beta and production channels, builds the product (or re-ships a previous build to a different channel), codesigns all components with Developer ID per Apple TN2206, builds the Help Book from Markdown…
#!/usr/bin/perl
=com
PURPOSE
This script will
Force you through a comprehensive quality-control checklist
Run Deploymate
Get the latest version number by reading it from product's Info.plist
@jerrykrinock
jerrykrinock / StarkEditor.h
Created December 4, 2013 19:56
This code is in response to a question on Stack Overflow wherein Jan Doggen asked if I could share my code. Probably won't be very helpful, but I'm all for sharing code, even if it happens to be Objective-C :) The general subject is: A general method for editing trees - methods which will add, remove, copy, move etc. nodes in the tree. Regarding…
#import <Cocoa/Cocoa.h>
#import "BkmxAppDel.h"
#import "BkmxGlobals.h"
enum BkmxParentingAction_enum
{
BkmxParentingActionNone, // 0
BkmxParentingAdd, // 1
BkmxParentingRemove, // 2
BkmxParentingCopy, // 3