Skip to content

Instantly share code, notes, and snippets.

View jeremytregunna's full-sized avatar

Jeremy Tregunna jeremytregunna

View GitHub Profile
Rehearsal -----------------------------------------------
instan_eval 0.258967 0.019441 0.278408 ( 0.485533)
bind.call 0.078391 0.003822 0.082213 ( 0.124251)
-------------------------------------- total: 0.360621sec
user system total real
instan_eval 0.259275 0.004492 0.263767 ( 0.309966)
bind.call 0.042689 0.000107 0.042796 ( 0.043009)
#import <Foundation/Foundation.h>
@interface NSArray (SafeAccess)
- (instancetype)withoutNulls;
- (instancetype)arrayByRemovingObjectsOfClass:(id)obj;
- (id)objectAtIndex:(NSUInteger)index ifKindOf:(Class)kind;
- (id)objectAtIndex:(NSUInteger)index ifKindOf:(Class)kind defaultValue:(id)defaultValue;
@johanneswuerbach
johanneswuerbach / .travis.yml
Last active May 14, 2024 03:50
Deploy an iOS app to testflight using Travis CI
---
language: objective-c
before_script:
- ./scripts/travis/add-key.sh
after_script:
- ./scripts/travis/remove-key.sh
after_success:
- ./scripts/travis/testflight.sh
env:
global:
@brentsimmons
brentsimmons / gist:5810992
Last active January 3, 2021 02:22
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
@coffeemug
coffeemug / gist:6168031
Last active October 15, 2024 01:08
The fun of implementing date support
After spending the better part of the month implementing date support
in RethinkDB, Mike Lucy sent the team the following e-mail. It would
have been funny, if it didn't cause thousands of programmers so much
pain. Read it, laugh, and weep!
-----
So, it turns out that we're only going to support dates between the
year 1400 and the year 10000 (inclusive), because that's what boost
supports.
@txus
txus / RATIONALE.md
Last active December 29, 2015 02:29
New API proposal for (block/closure) compilers in Rubinius

For language developers on the Rubinius platform, the APIs to the Rubinius generator and other compiler parts are generally very smooth and easy to use. An exception to this is when trying to generate a function/closure. Messing with the low-level APIs turns out to be unwieldy, as they tend to expose quite a lot of detail about Ruby-specific semantics.

The goal of this proposal is to provide a higher-level API optimized for a more general use case.

The file ast.rb contains the user code, and the file new_api.rb contains the support code to make it work (what would end up being implemented in some rubinius gem).

@angelolloqui
angelolloqui / AGCommand.h
Last active May 15, 2018 10:33
Advanced NSObject additions to handle commands
@interface AGCommand : NSObject
@property(nonatomic, weak) UIResponder *firingObject;
@property(nonatomic, readonly) SEL action;
+ (instancetype)command;
@end
Your goals are to reduce the number of things that you have to keep in your head at any given moment, and to rely as little as possible on your own ability to consistently do things right.
If you make a thing immutable ('let' in swift), you never have to think about what happens if it changes, or what other parts of the code you'll effect if you change it.
If you split complex functions into several smaller functions that only interact by passing arguments or getting return values, then you limit the amount of code you need to consider when hunting for a bug, and you can test each small piece separately.
If you understand what things must be true in your code (aka invariants, for example "a person's age must be greater than 0"), and either provide no function that can cause them to be untrue, or check and crash immediately when they're untrue, then you don't have to debug issues caused by incorrect assumptions.
If you remove possibilities (for example, Swift removes the possibility of things being nil unless

Turning Off Github Issues

My friend Michael Jackson turned off github issues on one of his smaller projects. It got me thinking...

Maintainers getting burned out is a problem. Not just for the users of a project but the mental health of the maintainer. It's a big deal for both parties. Consumers want great tools, maintainers want to create them, but maintainers don't want to be L1 tech support, that's why they

@jeremytregunna
jeremytregunna / symbolizing_osx_crash_logs.md
Created January 7, 2017 04:21 — forked from bmatcuk/symbolizing_osx_crash_logs.md
How to symbolize OSX crash logs

How to Symbolize OSX Crash Logs

Unfortunately, xcode does not yet have support for importing OSX crash logs and symbolizing them. Therefore, you must use the command line and a little bit of manual work.

  1. Find your dSYM file.
    1. Assuming you are using xcode's archive functionality, open the Organizer window from the Window menu.
    2. Click the Archives tab.
    3. Right click on the appropriate build and select Show in Finder.
    4. When Finder opens, right click on the selected archive and select Show Package Contents.
    5. Navigate to the dSYM directory and copy the appropriate dSYM file to a temporary directory.
  2. Then navigate to Products, then Applications, and copy the app file to the same temporary directory.