This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct BinaryTree { | |
char info; | |
struct BinaryTree *left, *right, *father; | |
} BinaryTree; | |
typedef struct { | |
BinaryTree *node; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static CGPathRef createClosedPathWithPoints(const CGPoint *points, size_t count) { | |
CGMutablePathRef path = CGPathCreateMutable(); | |
CGPathAddLines(path, NULL, points, count); | |
CGPathCloseSubpath(path); | |
return path; | |
} | |
static CGRect integralFrameForPath(CGPathRef path) { | |
CGRect frame = CGPathGetBoundingBox(path); | |
return CGRectIntegral(frame); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <ImageIO/ImageIO.h> | |
#import <MobileCoreServices/MobileCoreServices.h> | |
static UIImage *frameImage(CGSize size, CGFloat radians) { | |
UIGraphicsBeginImageContextWithOptions(size, YES, 1); { | |
[[UIColor whiteColor] setFill]; | |
UIRectFill(CGRectInfinite); | |
CGContextRef gc = UIGraphicsGetCurrentContext(); | |
CGContextTranslateCTM(gc, size.width / 2, size.height / 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <vector> | |
// index 0 is the least significant digit | |
typedef std::vector<uint16_t> BigInt; | |
static void insertDecimalDigit(BigInt &b, uint16_t decimalDigit) { | |
uint32_t carry = decimalDigit; | |
for (size_t i = 0; i < b.size(); ++i) { | |
uint32_t product = b[i] * (uint32_t)10 + carry; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static UIImage *imageWithSize(CGSize size) { | |
static CGFloat const kThickness = 20; | |
static CGFloat const kLineWidth = 1; | |
static CGFloat const kShadowWidth = 8; | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0); { | |
CGContextRef gc = UIGraphicsGetCurrentContext(); | |
CGContextAddArc(gc, size.width / 2, size.height / 2, | |
(size.width - kThickness - kLineWidth) / 2, | |
-M_PI / 4, -3 * M_PI / 4, YES); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This is a set of bash function definitions, and a bash command, that | |
# set up bash completion for the Mac OS X "open" command. | |
# | |
# HOW TO USE | |
# | |
# Add this command to your .bashrc: | |
# | |
# . open.sh | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController { | |
UIView *containerView; | |
NSArray *subviews; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command script import ~/Library/lldb/sniff_objc_exception_throw.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# command alias rd expression -o -- [[UIApp keyWindow] recursiveDescription] | |
command regex rd 's/^[[:space:]]*$/po [[UIApp keyWindow] recursiveDescription]/' 's/^(.+)$/po [%1 recursiveDescription]/' | |
command regex rsd 's/.*/po [UIApp Rob_recursiveSceneDescription]/' | |
command script import ~/.../lldb/sniff_objc_exception_throw.py | |
command regex hcons 's/^(.+)$/po [(id)%1 constraintsAffectingLayoutForAxis:0]/' | |
command regex vcons 's/^(.+)$/po [(id)%1 constraintsAffectingLayoutForAxis:1]/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
NSString *identifier = segue.identifier; | |
if (identifier.length == 0) | |
return; | |
NSString *selectorString = [NSString stringWithFormat:@"prepareFor%@Segue:sender:", identifier]; | |
SEL selector = NSSelectorFromString(selectorString); | |
if (!selector || ![self respondsToSelector:selector]) | |
return; | |
void (*method)(id, SEL, id, id) = (void (*)(id, SEL, id, id))[self methodForSelector:selector]; | |
method(self, selector, segue, sender); |