Skip to content

Instantly share code, notes, and snippets.

View dlinsin's full-sized avatar

David Linsin dlinsin

View GitHub Profile
@conradev
conradev / simulatorconsole
Last active December 16, 2015 00:45
simulatorconsole
#!/bin/bash
tail -f $(ls -t "$HOME/Library/Logs/CoreSimulator/"*/system.log | head -1)
@steipete
steipete / Macros.h
Last active January 6, 2024 07:24
Declare on your main init that all other init methods should call. It's a nice additional semantic warning. Works with Xcode 5.1 and above. Not tested with earlier variants, but should just be ignored. A reference to this macro shortly appeared in https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObj…
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
@chrismiles
chrismiles / reveal.py
Last active September 2, 2021 00:26
Lazy script to wrap Reveal lib load/start commands in one LLDB command.
""" File: reveal.py
Add to ~/.lldbinit:
command script import ~/.lldb-scripts/reveal.py
Q: Want to automatically load the Reveal lib on launch while debugging from Xcode?
A: In Xcode:
Add a Symbolic Breakpoint
Symbol: "UIApplicationMain"
Action: Debugger Command with value "reveal"
@steipete
steipete / DevelopmentEnviromentDetector.m
Last active October 30, 2019 03:49
Detect if you're currently running a development version or an App Store/Ad Hoc version.
static BOOL PSPDFIsDevelopmentBuild(void) {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
static BOOL isDevelopment = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// There is no provisioning profile in AppStore Apps.
NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]];
if (data) {
@chbeer
chbeer / other c flags
Last active December 21, 2015 17:18
My current "other c flags" setting for get a good amount of warnings and turn the most important/dangerous warnings into errors.
-Wall
-Wno-deprecated-declarations
-Werror=incompatible-pointer-types
-Werror=arc-retain-cycles
-Werror=implicit-function-declaration
-Werror=return-type
-Werror=format
-Werror=mismatched-parameter-types
-Werror=tautological-constant-out-of-range-compare
@toblerpwn
toblerpwn / CustomCollectionFlowLayout.h
Last active April 5, 2022 22:11
Sticky Headers at the top of a UICollectionView! -- // -- http://stackoverflow.com/questions/13511733/how-to-make-supplementary-view-float-in-uicollectionview-as-section-headers-do-i -- // -- still needs work around contentInsets.bottom and oddly-sized footers.
//
// CustomCollectionFlowLayout.h
// evilapples
//
// http://stackoverflow.com/questions/13511733/how-to-make-supplementary-view-float-in-uicollectionview-as-section-headers-do-i
//
//
#import <UIKit/UIKit.h>
@steipete
steipete / gist:4666527
Created January 29, 2013 18:43
Exif -> UIImageOrientation
// Convert an EXIF image orientation to an iOS one.
// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html
+ (UIImageOrientation) exifOrientationToiOSOrientation:(int)exifOrientation {
UIImageOrientation o = UIImageOrientationUp;
switch (exifOrientation) {
case 1: o = UIImageOrientationUp; break;
case 3: o = UIImageOrientationDown; break;
case 8: o = UIImageOrientationLeft; break;
case 6: o = UIImageOrientationRight; break;
@twobitlabs
twobitlabs / gist:4226365
Created December 6, 2012 17:35
Blocks cheat sheet
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
@mayoff
mayoff / UIBezierPath+forEachElement.h
Created December 2, 2012 06:51
dragging an object along a CGPath on iOS demo
#import <UIKit/UIKit.h>
@interface UIBezierPath (forEachElement)
- (void)forEachElement:(void (^)(CGPathElement const *element))block;
@end
@statonjr
statonjr / reminders.scpt
Created July 27, 2012 11:51
Write out Reminders to file on desktop
tell application "Reminders"
set todo_accounts to every account
-- accounts have lists. loop thru accounts to get their lists.
repeat with i from 1 to length of todo_accounts
tell account i
set todo_lists to get every list
-- lists have reminders. loop thru lists to get their reminders
repeat with j from 1 to length of todo_lists
tell list j
set todos to (get reminders)