Skip to content

Instantly share code, notes, and snippets.

View stevemoser's full-sized avatar
🐫
🥶

Steve Moser stevemoser

🐫
🥶
View GitHub Profile
@steventroughtonsmith
steventroughtonsmith / HWKViewController.m
Last active May 31, 2020 23:55
Example of dynamic iOS UI that changes based on the connection/disconnection of a hardware keyboard, based on suggestions from @JohnRHeaton. Requires linking to private GraphicsServices framework. rdar://problem/15447952
//
// HWKViewController.m
// HardwareKeyboardUI
//
// Created by Steven Troughton-Smith on 13/11/2013.
// Copyright (c) 2013 High Caffeine Content. All rights reserved.
//
#import "HWKViewController.h"
@markrickert
markrickert / fix-xcode.rb
Last active February 2, 2020 01:31
Quick fix to all your Xcode SDK issues. When you update Xcode, just run this script and all is well.
#!/usr/bin/env ruby
# fix-xcode
# Mark Rickert <mjar81@gmail.com>
# Symlinks all your old SDKs to Xcode.app every time it is updated.
# Create a directory called /SDKs and run this script.
#
# Each time you upgrade Xcode, run fix-xcode.
@gonzalolarralde
gonzalolarralde / tvos_prohibited.md
Last active December 24, 2019 16:19
Classes and Methods prohibited to tvOS
$ grep -lR "__TVOS_PROHIBITED" . | while read L; do echo "## $L"; echo "\`\`\`obj-c"; grep "__TVOS_PROHIBITED" "$L"; echo "\`\`\`"; echo; done

./AVFoundation.framework/AVAudioSession.h

AVAudioSessionPortOverrideSpeaker __TVOS_PROHIBITED = 'spkr'

AVAudioSessionCategoryOptionAllowBluetooth	__TVOS_PROHIBITED		= 0x4,
AVAudioSessionCategoryOptionDefaultToSpeaker __TVOS_PROHIBITED		= 0x8,
@danielctull
danielctull / AppDelegate.m
Last active April 12, 2019 07:15
Shows selection of table view cells on pressing the up/down arrow keys.
@implementation AppDelegate
#pragma mark - Key Command Controller
- (KeyCommandController *)keyCommandController {
if (!_keyCommandController) {
UIViewController *rootViewController = self.window.rootViewController;
if (rootViewController){
@steventroughtonsmith
steventroughtonsmith / gist:7515380
Last active April 2, 2019 01:38
iOS 7 UIKeyCommand keydown/keyup and keycode input implementation for a UIResponder. Private API, of course…
-(BOOL)canBecomeFirstResponder
{
return YES;
}
-(UIKeyCommand *)_keyCommandForEvent:(UIEvent *)event // UIPhysicalKeyboardEvent
{
NSLog(@"keyCommandForEvent: %@\n\
type = %i\n\
keycode = %@\n\
@steipete
steipete / UITableViewMore.m
Last active January 29, 2018 14:19
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
# Usage:
# 1) Ctr+S downloads page to ~/Desktop/books.html
# 2) Run script
# 3) Find your books in /tmp/humble_books
# 4) Read them
# 5) Profit
cat ~/Desktop/books.html |
grep "https://dl.humble.com" |
sed -n -E 's/.data-web\=\"(https://dl.humble.com/([.]+).([a-z]+)?["]+)./\1 \2 \3/p' |
sed 's/&amp;/&/g' > /tmp/humble_books_list && cat /tmp/humble_books_list |
@b3ll
b3ll / UIActivityViewControllerPreheat.swift
Created February 21, 2017 09:19
UIActivityViewController is crazy slow :(
// Preheat the UIActivityViewController because it's crazy slow.
let activityViewController = UIActivityViewController(activityItems: [ UIImage(named: "Halo.jpg")! ], applicationActivities: nil)
activityViewController.view.alpha = 0.0
let fakeViewController = UIViewController()
fakeViewController.present(activityViewController, animated: false) {
activityViewController.dismiss(animated: false, completion: nil)
}
@HEYGUL
HEYGUL / resign.sh
Created December 7, 2012 14:22 — forked from RichardBronosky/resign.sh
A simple tool for resigning an iOS app ipa with a new certificate/mobileprovision
#!/usr/bin/env bash
if [[ ! ( # any of the following are not true
# 1st arg is an existing regular file
-f "$1" &&
# ...and it has a .ipa extension
"${1##*.}" == "ipa" &&
# 2nd arg is an existing regular file
-f "$2" &&
# ...and it has an .mobileprovision extension
@mikeash
mikeash / test.m
Created July 9, 2012 21:15
Cocoa array slicing
// clang -framework Foundation -fobjc-arc -O3 test.m
#import <Foundation/Foundation.h>
@interface Slice : NSObject
@property NSInteger start;
@property NSInteger length;
@end
@implementation Slice