Skip to content

Instantly share code, notes, and snippets.

View iccir's full-sized avatar

Ricci Adams iccir

View GitHub Profile
@iccir
iccir / fix_pw_sierra_beta.command
Last active August 17, 2016 06:27
Fixes Pixel Winch on macOS Sierra Beta
#
# Due to a change with the App Sandbox, Pixel Winch 1.1 cannot capture screenshots
# in the beta version of macOS Sierra. As a workaround until Sierra GM, run the below commands.
#
# For more information, if you are a third party developer, check out:
# https://eternalstorms.wordpress.com/2016/08/01/screencapture-and-the-sandbox-in-macos-sierra/
# https://forums.developer.apple.com/message/152226#152226
#
# If you are an Apple engineer, check out:
# 27245600, 27610157, 27735823
@iccir
iccir / gist:5d1d8aff2335e308780f
Created December 2, 2015 10:01
Sketch Migration Notes
I tried to migrate to the non-MAS version of Sketch and had problems.
Steps I took:
1) I launched New Sketch. I entered my e-mail address. No e-mail received.
2) I launched MAS Sketch. It crashed at launch and told me the app was damaged.
3) Ok, no problem, I trashed the app and reinstalled from the MAS's purchases tab
4) Download appeared in /Applications. When MAS got to 100%, download disappeared. I've seen this before with MAS software.
5) I had to trash the new version of Sketch as well, *and* empty trash.
6) Re-download from the MAS.
#!/usr/bin/ruby
require "json"
all_strings = [ ]
`find . -path "*en.lproj*/*.strings"`.each_line do |line|
JSON.parse(`plutil -convert json -o - \"#{line.chop}\"`).each_value do |value|
all_strings.push(value.strip)
end
@iccir
iccir / push.m
Last active May 31, 2019 03:44
How to push a portrait-only UIViewController onto a landscape UINavigationController
// How to push a portrait-only UIViewController onto a landscape UINavigationController
- (void) _presentForcedVerticalNormalViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIView *(^makeSnapshotOfViewController)(UIViewController *) = ^(UIViewController *vc) {
UIView *result = [[vc view] snapshotViewAfterScreenUpdates:NO];
[[_rootViewController view] addSubview:result];
[result setFrame:[[vc view] bounds]];
[result setUserInteractionEnabled:NO];
@iccir
iccir / IXDebugTouchEvents.m
Last active September 1, 2015 23:03
IXDebugTouchEvents()
// IXDebugTouchEvents() will flash the view that receives a touch event
BOOL IXSwizzleMethod(Class cls, SEL selA, SEL selB)
{
Method methodA = class_getInstanceMethod(cls, selA);
if (!methodA) return NO;
Method methodB = class_getInstanceMethod(cls, selB);
if (!methodB) return NO;
@iccir
iccir / alert.m
Last active September 6, 2015 00:31
MakeAlert()
extern UIAlertController *MakeAlert(NSString *title, NSString *message, NSString *cancelText, NSString *confirmText, void (^confirmBlock)(BOOL confirmed));
extern UIAlertController *MakeAlert(NSString *title, NSString *message, NSString *cancelText, NSString *confirmText, void (^confirmBlock)(BOOL confirmed))
{
UIAlertController *result = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
if (!confirmText) confirmText = NSLocalizedString(@"OK", nil);
if (!cancelText) cancelText = NSLocalizedString(@"Cancel", nil);
[result addAction:[UIAlertAction actionWithTitle:cancelText style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
@iccir
iccir / messages.js
Created August 30, 2015 03:44
MIDI Messages
// See chart at http://www.midi.org/techspecs/midimessages.php
function handleMIDIMessage(message)
{
var status = message.data[0];
var note = message.data[1];
var velocity = message.data[2];
var type = status >> 4;
var channel = status & 0xf;
# Due to an issue with the App Sandbox, Pixel Winch 1.0 will crash when the user
# attempts to save a screenshot or import an image. I'm submitting 1.0.1 immediately
# to fix this.
#
# In the meantime, if you need save/import functionality, a workaround is to disable the App Sandbox
# for Pixel Winch entirely:
defaults write /tmp/disable_sandbox.plist com.apple.security.app-sandbox -bool false
sudo codesign -f --entitlements /tmp/PixelWinchFix.plist -s - /Applications/Pixel\ Winch.app
<?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">
<dict>
<key>name</key>
<string>Xcode-ish</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@iccir
iccir / gist:9c1700d28d51f34afa75
Created January 6, 2015 03:22
iOS 8: 9:41 AM status bar overrides
// Enable 9:41 AM status bar override for easy promo screenshot creation. Works on both device and in simulator
NSInteger (*SBSSpringBoardServerPort)() = dlsym(RTLD_NEXT, "SBSSpringBoardServerPort");
NSInteger (*SBSetShowsOverridesForRecording)(NSInteger, NSInteger) = dlsym(RTLD_NEXT, "SBSetShowsOverridesForRecording");
SBSetShowsOverridesForRecording(SBSSpringBoardServerPort(), 1);