Skip to content

Instantly share code, notes, and snippets.

View asmallteapot's full-sized avatar
😴
😴

Ellen Teapot asmallteapot

😴
😴
View GitHub Profile
// context docs: https://paw.cloud/docs/reference/ExtensionContext
// request docs: https://paw.cloud/docs/reference/Request
// DynamicString docs: https://paw.cloud/docs/reference/DynamicString
// DynamicValue docs: https://paw.cloud/docs/reference/DynamicValue
function logRequestVariableInfo(requestVariable) {
console.log('Request Variable: ' + requestVariable.name + '\n' +
' Request: ' + requestVariable.request.name + '\n' +
' Value: ' + requestVariable.value + '\n' +
' Description: ' + requestVariable.description + '\n' +
@brennanMKE
brennanMKE / Async.swift
Last active March 6, 2023 13:01
Blocking with Semaphores and DispatchGroups in Swift
import PlaygroundSupport
import Foundation
class Worker {
private let queue = DispatchQueue.global(qos: .background)
private let serialQueue = DispatchQueue(label: "com.acme.serial")
public private(set) var count = 0
func incrementCount() {
// license: i dunno. pick one that works for you. Apache 2.0? that seems reasonable. Let me know if it doesn't work for some reason.
import Foundation
import Compression // https://developer.apple.com/library/mac/documentation/Performance/Reference/Compression/
public enum Compression {
public enum Algorithm {
case LZFSE
case LZ4
case LZMA
@steipete
steipete / ios-xcode-device-support.sh
Last active October 14, 2024 16:35
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@simonw
simonw / how-to.md
Last active April 16, 2025 15:21
How to create a tarball of a git repository using "git archive"
@ZevEisenberg
ZevEisenberg / LICENSE
Last active February 19, 2022 02:04
Smoothly deselect table and collection view cells on dismissal, including interactive dismiss and interactively-partially-dismiss-then-cancel-then-dismiss-again
The MIT License (MIT)
Copyright (c) 2016 Zev Eisenberg
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@pietbrauer
pietbrauer / Makefile
Created April 26, 2015 10:03
Shutdown and reset all iOS Simulators
erase_sim:
./reset_sim.sh 2>/dev/null; true
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@zwaldowski
zwaldowski / UIFontDescriptor+DynamicType.m
Created November 9, 2014 22:06
Dynamic Type with Weight-Matching
@implementation UIFontDescriptor (DZWDynamicType)
+ (instancetype)dzw_preferredFontDescriptorWithTextStyle:(NSString *)style {
return [[self preferredFontDescriptorWithTextStyle:style] dzw_fontDescriptorWithMatchingFamily:@"Avenir Next"];
}
- (instancetype)dzw_fontDescriptorWithMatchingFamily:(NSString *)family {
NSMutableDictionary *attributes = [self.fontAttributes mutableCopy];
[attributes removeObjectForKey:UIFontDescriptorTextStyleAttribute];
UIFontDescriptor *newDesc = (__bridge_transfer UIFontDescriptor *)CTFontDescriptorCreateCopyWithFamily((__bridge CTFontDescriptorRef)self, (__bridge CFStringRef)family);
@drance
drance / AppleTVName
Created November 3, 2014 20:45
Get the currently-routed AppleTV's name.
// Use in conjunction with e.g. KVO on AVPlayer.externalPlaybackActive
AVAudioSessionPortDescription *port = [AVAudioSession sharedInstance].currentRoute.outputs.firstObject;
if ([port.portType isEqualToString:AVAudioSessionPortAirPlay]) {
NSLog(@"Now playing on '%@'", port.portName);
}