Skip to content

Instantly share code, notes, and snippets.

View endocrimes's full-sized avatar

Danielle endocrimes

View GitHub Profile
@hamzasood
hamzasood / gist:02e6e87835a17f4e1b9e
Created November 23, 2015 23:15
Apple Pencil 3D Touch
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
// Hook with ObjC runtime functions
%config(generator=internal)
// New methods created below
@interface UIGestureRecognizer ()
+ (void)hs_beginForcingAllNewGestureRecognizersToAllowPencilInput;
+ (void)hs_endForcingAllNewGestureRecognizersToAllowPencilInput;
@vfig
vfig / iosdev.markdown
Last active November 11, 2015 09:56
iOS dev command line operations that I find useful but have trouble remembering

Provisioning profiles

Find UUIDs of provisioning profiles in current directory:

find . -name '*.mobileprovision' -print0 | xargs -0 -t -n 1 security cms -D -i | grep -A1 UUID 2>&1

Convert .mobileprovision to .plist

security cms -D -i foo.mobileprovision -o foo.plist

Extract signing certificate from provisioning profile plist

@neonichu
neonichu / podenv.rb
Last active March 1, 2020 07:13
A simple CocoaPods version manager.
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
def install_gem(name, version)
require 'rubygems/commands/install_command'
cmd = Gem::Commands::InstallCommand.new
cmd.handle_options [name, '--version', version]
begin
** BUILD SUCCEEDED **
85.61 real 116.49 user 28.51 sys
- CPU: http://cl.ly/Z8b3
- Fans: Never spun up
- Heat: not noticeable
@neonichu
neonichu / implementationWithBlock.swift
Created September 29, 2014 08:17
How to use imp_implementationWithBlock in Swift
import Foundation
import ObjectiveC.runtime
let myString = "foobar" as NSString
println(myString.description)
let myBlock : @objc_block (AnyObject!) -> String = { (sself : AnyObject!) -> (String) in
"✋"
}
@alexrepty
alexrepty / PlaceholderOrder.m
Created September 26, 2014 12:50
I learned about %1$@, %2$@ etc. today thanks to Wordcrafts
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
NSString *foo = @"foo";
NSString *bar = @"bar";
NSString *oldSkool = [NSString stringWithFormat:@"%@ %@", foo, bar];
NSString *original = [NSString stringWithFormat:@"%1$@ %2$@", foo, bar];
@seivan
seivan / gist:b0a281c6d7f4a75d50de
Created June 27, 2014 18:54
I can't believe this actually worked O_o
protocol ScalarArithmetic {
var acos:Self {get}
var asin:Self {get}
var atan:Self {get}
func atan2(x:Self) -> Self
var cos:Self {get}
var sin:Self {get}
var tan:Self {get}
var exp:Self {get}
var exp2:Self {get}
@kristopherjohnson
kristopherjohnson / cout.swift
Last active August 29, 2015 14:02
C++-style stream output for Swift. (For fun only: Never, ever use this.)
import Foundation
// Swift's << operator is not left-associative, so we'll use <<< instead
operator infix <<< { associativity left }
// Output operator for Streamable objects
func <<< (var outputStream: OutputStream, streamable: Streamable) -> OutputStream {
// Note: It seems like streamable.writeTo(&outputStream) should work, but playground crashes,
// so we write to a string and then output the string
var outputString = ""
@Inferis
Inferis / ViewController.swift
Last active December 1, 2019 23:27
Beginnings of a GCD wrapper in swift
import UIKit
import QuartzCore
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel
@IBOutlet weak var counter: UILabel
override func viewDidLoad() {
super.viewDidLoad()