Skip to content

Instantly share code, notes, and snippets.

View timsutton's full-sized avatar
🍁

Timothy Sutton timsutton

🍁
View GitHub Profile
@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,
@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
@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

@Faheetah
Faheetah / Jenkinsfile.groovy
Last active May 6, 2024 20:49
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"
@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
@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; }
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)
@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
@jacobblock
jacobblock / FreeNAS.md
Last active October 22, 2023 13:01
Ultimate FreeNAS Setup

FreeNAS

I started using FreeNAS in August 2013. It is fantastic piece of software and I have been really impressed by the upgrades just in the few months I've been using it. It looks like they recently went to a plugin system as of version 9 to make installing software easier for end users. I've ran into several issues related to plugins and user + group permissions so I decided to just use the available FreeBSD port system. After fiddling for a few days (now turned into months) I believe I have created something helpful for the community and anyone interested in picking up the port system. The sandbox nature of FreeNAS's jail system is especially helpful for playing around without having any consequence on your core system.

Here are straight-forward instructions to setting up a bunch of different software on FreeNAS. If you make a terrible error, just throw up another plugin sandbox and repeat.

ToC

@pudquick
pudquick / http_flatpkg_pkginfo.py
Created May 11, 2014 07:13
This python project is able to retrieve the PackageInfo metadata from flatpkg files over HTTP without downloading the entire .pkg file (if the web server it's hosted on supports partial file transfer / byte ranges)
# Skip to the end to see what this can do.
#
# http://s.sudre.free.fr/Stuff/Ivanhoe/FLAT.html
# Flat packages are xar files with a particular structure
# We're looking for the PackageInfo file within the xar file
import urllib2, ctypes, zlib
import xml.etree.ElementTree as ET
class SimpleObj(object):