Skip to content

Instantly share code, notes, and snippets.

@krackers
krackers / LegacyDocsets.md
Created August 23, 2023 22:10 — forked from fzwo/LegacyDocsets.md
Download and view old Apple developer documentation

How to download and view legacy documentation from Apple (no need to sign in to your dev account)

  1. Download the docset index XML.
  2. Find the docset you want (there are some with URL https://apple.com/none.dmg; ignore them - you will find them again further down the file with a working URL).
  3. Download the dmg. It's probably around a gigabyte or so.
  4. "Install" the .pkg file somewhere on your disk. If you don't trust the installer, do it manually:
    1. Find the largest file, named Payload, and extract it using The Unarchiver.
    2. This creates a new, even larger file, probably named Payload-1.
    3. Extract Payload-1 using The Unarchiver.
  5. After many minutes of extracting, we have our .docset file.
@krackers
krackers / swizzler.h
Last active August 20, 2023 00:19 — forked from saagarjha/swizzler.h
Type-safe, RAII swizzler for Objective-C++
// https://twitter.com/_saagarjha/status/1692839886053625917#m
#import <Foundation/Foundation.h>
#import <atomic>
#import <memory>
#import <objc/runtime.h>
#include <objc/message.h>
#import <stdexcept>
#import <iostream>
@krackers
krackers / README.md
Created June 12, 2023 02:57 — forked from Mnkai/README.md
TDP and turbo parameter modification with MSR on non-overclockable Intel CPU (such as Intel i7-8550U)

TDP and turbo parameter modification with MSR on non-overclockable CPU

Disclaimer

  • MSR modification may void your CPU's (or system board's) warranty. Proceed with care. I'm not responsible for any destruction caused by this article.
  • MSR address (greatly) differs from CPU to CPU. Check your own CPU's MSR address using Intel's documentation.
  • Only tested on Intel i7-8550U (Kaby Lake R).
  • This article is translation of this article. If you can understand Korean, I recommend reading that article, not this.

Start

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
@krackers
krackers / macOS Internals.md
Created May 7, 2023 05:22 — forked from kconner/macOS Internals.md
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:

@krackers
krackers / ObjectiveCDebounce.md
Created May 6, 2023 23:55 — forked from stevenojo/ObjectiveCDebounce.md
Objective-C Debounce Example Using GCD Dispatch Sources / Timer

##Debouncing using GCD on iOS

The idea of "Debouncing" is to limit the rate a function or task can execute by waiting a certain amount of time before executing it. In the example below, if a user rapidly enters input, it will only execute once, 1 second after all that input. This is the implementation of a sample class showing how to do so, while using Grand Central Dispatch to create a timer. The timer fires on a global queue in this example - but you can change the queue to any queue where you want the timer to execute, regardless of where you set it up.

#import <Foundation/Foundation.h>

@interface DebounceExample : NSObject
@krackers
krackers / libdispatch-efficiency-tips.md
Created April 23, 2023 21:47 — forked from tclementdev/libdispatch-efficiency-tips.md
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

@krackers
krackers / globalThis-polyfill.js
Created February 23, 2023 22:08 — forked from bingo347/globalThis-polyfill.js
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;
})();
@krackers
krackers / matchAll polyfill.js
Created February 23, 2023 22:08 — forked from TheBrenny/matchAll polyfill.js
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!
};
}
@krackers
krackers / Test
Last active February 19, 2023 22:37
<html>
<head>
<title>Test</title>
<script type="text/javascript">
window.alert('Hello');
</script>