Skip to content

Instantly share code, notes, and snippets.

@kconner
kconner / macOS Internals.md
Last active November 13, 2024 07:51
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@regstuff
regstuff / Wayback Machine SPN2 API Docs
Created June 21, 2022 09:42
Wayback Machine SPN2 API Docs
From https://docs.google.com/document/d/1Nsv52MvSjbLb2PCpHlat0gkzw0EvtSgpKHu4mk0MnrA/
Save Page Now 2 Public API Docs Draft
Vangelis Banos, updated: 2022-04-05
Capture a web page as it appears now for use as a trusted citation in the future. Changelog: https://docs.google.com/document/d/19RJsRncGUw2qHqGGg9lqYZYf7KKXMDL1Mro5o1Qw6QI/edit#
Contents
Glossary 1
Basic API Reference 1
Capture request 1
@saagarjha
saagarjha / swizzler.h
Last active December 25, 2023 18:06
Type-safe, RAII swizzler for Objective-C++
// Example usage:
// Swizzler<NSString *, NSDateFormatter *, NSDate *> NSDateFormatter_stringFromDate_ {
// NSDateFormatter.class, @selector(stringFromDate:), [&](auto self, auto date) {
// if ([NSCalendar.currentCalendar components:NSCalendarUnitWeekday fromDate:date].weekday == 4) {
// return @"It Is Wednesday My Dudes";
// } else {
// return NSDateFormatter_stringFromDate_(self, date);
// }
// }
// };
@GetVladimir
GetVladimir / Force-RGB-Color-on-M1-Mac.md
Last active November 15, 2024 14:00
Force RGB Color on M1 Mac

Force RGB Color on M1 Mac

How to Force RGB Color Output instead of YPbPr on your M1 Apple Silicon Mac for an External Monitor.

This step-by-step video tutorial will guide you through the procedure of forcing RGB color output on your M1 Mac.

Force RGB Color on M1 Mac

Here is the direct link to the video tutorial: https://www.youtube.com/watch?v=Z1EqH3fd0V4

The video also has Closed Captions (Subtitles) that you can enable, to make it easier to follow if needed.

@hzhu212
hzhu212 / python_stream.md
Last active August 25, 2023 09:22
Python iterator with chain-call like Java stream

Python Stream object act like Java Stream, features include lazy calculating, slicing, chain-call etc.

stream.py:

import functools
import itertools


class Stream(object):
@TheBrenny
TheBrenny / matchAll polyfill.js
Last active February 24, 2023 19:23
A polyfill for the String.prototype.matchAll method. Only available in Node12+ and most browsers.
if(!String.prototype.matchAll) {
String.prototype.matchAll = function (rx) {
if (typeof rx === "string") rx = new RegExp(rx, "g"); // coerce a string to be a global regex
rx = new RegExp(rx); // Clone the regex so we don't update the last index on the regex they pass us
let cap = []; // the single capture
let all = []; // all the captures (return this)
while ((cap = rx.exec(this)) !== null) all.push(cap); // execute and add
return all; // profit!
};
}
#!/usr/bin/env python3
import z3
import pprint
# 9x9 matrix of integer variables
X = [ [ z3.Int("x_%s_%s" % (i+1, j+1)) for j in range(9) ]
for i in range(9) ]
# each cell contains a value in {1, ..., 9}
cells_c = [ z3.And(1 <= X[i][j], X[i][j] <= 9)
@bingo347
bingo347 / globalThis-polyfill.js
Created March 19, 2020 13:23
globalThis simple polyfil
(() => {
const isNotUndefined = typeofResult => typeofResult !== 'undefined';
if(isNotUndefined(typeof globalThis) && globalThis.globalThis === globalThis) { return; }
const g = (isNotUndefined(typeof window) && window)
|| (isNotUndefined(typeof global) && global)
|| (isNotUndefined(typeof self) && self)
|| Function('return this')();
g.globalThis = g;
})();
@adamschwartz
adamschwartz / pre-2020-google-search-results.css
Last active February 6, 2023 21:57
Stylesheet for pre-2020 Google Search results page styles
/* Version 3. Updated Sep 5, 2022 */
#search a:has(>br):has(>h3):has(>div) br {
display: none;
}
#search a:has(>br):has(>h3):has(>div) h3 {
display: block;
}
@gregcotten
gregcotten / CVPixelFormat Descriptions
Created August 29, 2019 18:45
All Public and Private CVPixelFormat Descriptions
Structure is [PixelFormatTitle: DescriptionDictionary]. PixelFormatTitle is the kCVPixelFormatType_ suffix (if known) and the FourCharCode as a string or int if the string is too short.
[["32ARGB / 32": {
BitsPerBlock = 32;
BitsPerComponent = 8;
BlackBlock = <ff000000>;
CGBitmapContextCompatibility = 1;
CGBitmapInfo = 16388;
CGImageCompatibility = 1;
ContainsAlpha = 1;