Skip to content

Instantly share code, notes, and snippets.

View timsutton's full-sized avatar
🍁

Timothy Sutton timsutton

🍁
View GitHub Profile
@pudquick
pudquick / cert_tricks.py
Last active August 29, 2015 14:08
SHA-1 PEM cert signature & CN extraction from a certificate via python on OS X
import base64, hashlib
from ctypes import CDLL, POINTER, Structure, create_string_buffer, byref
from ctypes.util import find_library
Security = CDLL(find_library('Security'))
# Importing this via C because haven't figured out how to mix in pyObjc version yet
c_CoreFoundation = CDLL(find_library('CoreFoundation'))
class OpaqueType(Structure):
pass
anonymous
anonymous / syncs.d
Created February 9, 2015 00:02
#!/usr/sbin/dtrace -q -s
/*
Overly spammy, mostly covered by the other probes (every "read" or "write" is a "request")
CFPreferencesServer$target:::request {
printf("REQUEST from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", arg0, walltimestamp, copyinstr(arg1) != NULL ? copyinstr(arg1) : "(NULL)" ?: "(NULL)", copyinstr(arg2) != NULL ? copyinstr(arg2) : "(NULL)", copyinstr(arg3) != NULL ? copyinstr(arg3) : "(NULL)", copyinstr(arg4) != NULL ? copyinstr(arg4) : "(NULL)", arg5);
}
*/
CFPreferencesServer$target:::write_rejected {
printf("REJECTED WRITE OF KEY %s request from pid %d for reason %s at %Y ( domain: %s, user: %s, host: %s, container: %s)\n", copyinstr(arg1) != NULL ? copyinstr(arg1) : "(NULL)", arg0, copyinstr(arg6) != NULL ? copyinstr(arg6) : "(NULL)", walltimestamp, copyinstr(arg2) != NULL ? copyinstr(arg2) : "(NULL)", copyinstr(arg3) != NULL ? copyinstr(arg3) : "(NULL)", copyinstr(arg4) != NULL ? copyinstr(arg4) : "(NULL)", copyinstr(arg5) != NULL ? copyinstr(arg5)
@tmslnz
tmslnz / apple-system-font.css
Created July 12, 2015 18:01
Specify Apple System Font in CSS
/* From http://furbo.org/2015/07/09/i-left-my-system-fonts-in-san-francisco/ */
* { font-family: -apple-system-font, HelveticaNeue, LucidaGrande; }
/* Dynamic Type feature */
* { font-family: -apple-system-headline1, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-headline2, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-body, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-subheadline1, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-subheadline2, HelveticaNeue, LucidaGrande; }
@pudquick
pudquick / framework_constants_via_pyobjc.py
Last active May 18, 2021 01:34
Loading framework variables (aka constants) from pyObjC for arbitrary frameworks
from Foundation import NSBundle
# Load the framework bundle by its identifier
Metadata_bundle = NSBundle.bundleWithIdentifier_("com.apple.Metadata")
# Can also use: bundleWithPath or bundleWithURL
# Load the variable aka constant from the framework into globals
# This says to load whatever "kMDSPreferencesName" is and the type should be "an NSObject" aka "figure it out"
# which ends up giving us a NSString which pyObjC bridges to a python string nicely
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active March 6, 2024 18:14
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@indrayam
indrayam / create-jwt-using-unix-commands-on-mac.md
Last active September 21, 2022 08:08
Create JWT Token Header Using Unix Command line tools ONLY!

Pseudocode:

Y = Base64URLEncode(Header) + ‘.’ + Base64URLEncode(Payload)
JWT = Y + ‘.’ + Base64URLEncode(HMACSHA256(Y))

The steps called out here should work on a Mac as well. The only thing that might be different is the sed command used below. Instead of using -E, you will have to use -r to run sed with extended regular expression support

Use data from this tutorial:

scotch.io

@zchee
zchee / Extra Logging for My Great App.mobileconfig
Created October 22, 2016 17:58 — forked from zwaldowski/Extra Logging for My Great App.mobileconfig
Apple Configuration Profile for Logging in iOS 10 and macOS Sierra
<?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">
<!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's
supposed to scale from the kernel, up to frameworks, and up to apps. It defaults
to a more regimented, privacy-focused approach that large apps and complex
systems need.
It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the
Console app in macOS Sierra, hope to help you graduate from caveman debugging to
@pudquick
pudquick / sip_config.py
Created December 22, 2016 22:31
Querying active SIP status directly from the kernel, bypassing nvram and csrutil, via python on macOS
# An overly complicated SIP config checker
# This is a technically interesting implementation because it does not rely on csrutil
# Instead it queries the kernel directly for the current configuration status
# This means, for example, in environments where SIP has been disabled and csrutil has
# been removed or modified (say, with DYLD_LIBRARY_PATH), as long as python can run you
# can still check status
# Additionally, checking the nvram csr-active-config setting isn't accurate now with
# 10.12.2+, since running "sudo csrutil clear" deletes the variable until reboot,
@pudquick
pudquick / xcode_get.py
Last active December 7, 2020 09:01
Stupid tricks: using stock macOS python subprocess with curl to download products from Apple's Developer Center
from subprocess import Popen, PIPE, STDOUT, check_output
from mimetools import Message
from StringIO import StringIO
from urlparse import urlparse, parse_qs
from urllib import quote, basejoin, urlencode
DEV_SITE = 'https://developer.apple.com'
AUTH_SITE = 'https://idmsa.apple.com'
AUTH_PATH = '/IDMSWebAuth/authenticate'
APPIDKEY_PATH = "/services-account/download?path=%s"
@magnetikonline
magnetikonline / README.md
Last active February 4, 2024 07:45
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.