Skip to content

Instantly share code, notes, and snippets.

View sgl0v's full-sized avatar

Max sgl0v

View GitHub Profile
@sgl0v
sgl0v / NSObject+Blocks.h
Created March 14, 2013 19:40 — forked from zwaldowski/NSObject+Blocks.h
Cancellable blocks
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
cd ${TARGET_TEMP_DIR}
# To check if this is up-to-date with the tax rates go to
# http://www.expatax.nl/tax_rates_2013.php and see if there's anything
# newer there.
use strict;
use warnings;
use Text::TabularDisplay;
use List::Util qw(sum);
my $start = 30_000 || $ARGV[0];
my $end = 100_000 || $ARGV[1];
#import <UIKit/UIKit.h>
@interface UIView (TLLayout)
@property (nonatomic, strong) NSArray *hiddenConstraints;
// set hidden and remove any constraints involving this view from its superview
- (void)hideAndRemoveConstraints;
- (void)showAndRestoreConstraints;
static Boolean PSPDFCaseInsensitiveEqualCallback(const void *a, const void *b) {
id objA = (__bridge id)a, objB = (__bridge id)b;
Boolean ret = FALSE;
if ([objA isKindOfClass:NSString.class] && [objB isKindOfClass:NSString.class]) {
ret = ([objA compare:objB options:NSCaseInsensitiveSearch|NSLiteralSearch] == NSOrderedSame);
}else {
ret = [objA isEqual:objB];
}
return ret;
}

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@sgl0v
sgl0v / gist:3509f3ae628f4047cdb6
Created October 28, 2015 12:56 — forked from macguru/gist:b7a01e3f0e9ae6f350d5
Interface sizes a regular Universal app must support with iOS 9.2 when supporting all devices. Starts with iPhone 4s and goes up to iPad Pro.
COMPACT WIDTH (stacked view)
- 320 x 480 pt
-> iPhone 4s
- 320 x 568 pt
-> iPhone 5, 5s
- 320 x 768 pt
-> iPad Slideover Landscape
-> iPad Split Landscape 2/3 right
- 320 x 1024 pt
@sgl0v
sgl0v / rand_string.m
Created November 10, 2015 14:06
Random string generator in ObjC
#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonCrypto.h>
NSString* randomString(NSUInteger length)
{
NSMutableData *data = [NSMutableData dataWithLength:length];
NSInteger result = SecRandomCopyBytes(kSecRandomDefault, length, data.mutableBytes);
NSLog(@"%ld", (long)result);
NSMutableString* str = [NSMutableString string];
for (int i = 0; i < length / 8; i++)
@sgl0v
sgl0v / JAZMusician.h
Created November 24, 2015 23:22 — forked from jpsim/JAZMusician.h
SourceKit Playground
//
// JAZMusician.h
// JazzyApp
//
#import <Foundation/Foundation.h>
/**
JAZMusician models, you guessed it... Jazz Musicians!
From Ellington to Marsalis, this class has you covered.
@sgl0v
sgl0v / gist:602be267b75b8303ceea
Created January 3, 2016 12:21 — forked from krzysztofzablocki/gist:4396302
Set symbol breakpoint on objc_msgSend then setup this debug command to log all methods called in iOS Simulator. If you want to do device debugging change esp+4 register to r0, esp+8 to r1 Found long ago somewhere on stackoverflow.
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) )