Skip to content

Instantly share code, notes, and snippets.

Charlton Provatas cprovatas

Block or report user

Report or block cprovatas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@BenLeggiero
BenLeggiero / Swift 4 - NSApp Relaunch.swift
Last active Aug 13, 2018
Allows you to re-launch a Cocoa app
View Swift 4 - NSApp Relaunch.swift
import Cocoa
public extension NSApplication {
public func relaunch(afterDelay seconds: TimeInterval = 0.5) -> Never {
let task = Process()
task.launchPath = "/bin/sh"
task.arguments = ["-c", "sleep \(seconds); open \"\(Bundle.main.bundlePath)\""]
@lattner
lattner / async_swift_proposal.md
Last active Oct 19, 2019 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift
View async_swift_proposal.md

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@ppamorim
ppamorim / ImageInsets.swift
Created Nov 5, 2015
Add padding/margin at a image!
View ImageInsets.swift
import UIKit
extension UIImage {
func imageWithInsets(insetDimen: CGFloat) -> UIImage {
return imageWithInset(UIEdgeInsets(top: insetDimen, left: insetDimen, bottom: insetDimen, right: insetDimen))
}
func imageWithInset(insets: UIEdgeInsets) -> UIImage {
UIGraphicsBeginImageContextWithOptions(
CGSizeMake(self.size.width + insets.left + insets.right,
@alloy
alloy / 1 - Find issue view
Last active Dec 1, 2017
Finding the Xcode issues navigator
View 1 - Find issue view
~/C/A/eigen [master] » lldb -p (pgrep '^Xcode$')
(lldb) process attach --pid 34726
Process 34726 stopped
Executable module set to "/Applications/Xcode-Beta.app/Contents/MacOS/Xcode".
Architecture set to: x86_64-apple-macosx.
(lldb) po [[NSApplication sharedApplication] windows]
<__NSArrayM 0x7fe18be755d0>(
<IDEWorkspaceWindow: 0x7fe18045ba40>,
<_NSFullScreenUnbufferedWindow: 0x7fe1841b18d0>,
<_NSFullScreenTransitionOverlayWindow: 0x7fe1841b3770>,
@steipete
steipete / UIKit.c
Created Nov 26, 2014
- [UIPopoverPresentationController dimmingViewWasTapped:] decompiled with Decompiled with IDA Pro 6.6.1 and the x86 Decompiler
View UIKit.c
// UIPopoverPresentationController - (void)dimmingViewWasTapped:(id)
void __cdecl -[UIPopoverPresentationController dimmingViewWasTapped:](struct UIPopoverPresentationController *self, SEL a2, id a3)
{
void *v3; // eax@2
void *v4; // eax@5
void *v5; // eax@6
void *v6; // eax@7
void *v7; // eax@8
if ( !objc_msgSend(self, selRef_delegate)
@steipete
steipete / UIKit.m
Created Nov 26, 2014
- [UIPopoverPresentationController dimmingViewWasTapped:] decompiled with Hopper 3.6.4
View UIKit.m
void -[UIPopoverPresentationController dimmingViewWasTapped:](void * self, void * _cmd, void * arg2) {
esi = self;
edi = @selector(delegate);
if ([esi delegate] != 0x0) {
eax = [esi delegate];
var_10 = @selector(popoverPresentationControllerShouldDismissPopover:);
eax = [eax respondsToSelector:@selector(popoverPresentationControllerShouldDismissPopover:)];
if (LOBYTE(eax) != 0x0) {
eax = [esi presented];
if (LOBYTE(eax) != 0x0) {
@matt-curtis
matt-curtis / gist:6b9235f3a3e94ce9145d
Last active Sep 11, 2017
Disable animation in UINavigationBar
View gist:6b9235f3a3e94ce9145d
@implementation MyNavBar
- (NSArray*) subviews {
NSArray *subviews = [super subviews];
if(_animationDisabled) [self removeAllAnimationsInViews:subviews];
return subviews;
}
@mikeash
mikeash / runtime-class.m
Created Nov 22, 2013
Creating a usable class purely at runtime using the Objective-C runtime APIs.
View runtime-class.m
// clang -fobjc-arc -framework Foundation runtime-class.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface Person : NSObject
- (id)initWithFirstName: (NSString *)firstName lastName: (NSString *)lastName age: (NSUInteger)age;
@kylefox
kylefox / gist:4512777
Created Jan 11, 2013
If you want to use Xcode's FileMerge as your git mergetool, this is how you set it up.
View gist:4512777
# Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff
@mbinna
mbinna / podforceupdate.sh
Created Dec 4, 2012
Clear CocoaPods cache, re-download and re-install all pods
View podforceupdate.sh
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
You can’t perform that action at this time.