Skip to content

Instantly share code, notes, and snippets.

@jpsim
jpsim / Alamofire.xml
Created October 14, 2014 21:06
SourceKitten Output
<jazzy>
<Other column="12" file="/Users/jp/Projects/Alamofire/Source/Alamofire.swift" line="26">
<Name>AlamofireErrorDomain</Name>
<USR>s:v9Alamofire20AlamofireErrorDomainSS</USR>
<Declaration>public let AlamofireErrorDomain: String</Declaration>
<Abstract>
<Para>Alamofire errors</Para>
</Abstract>
</Other>
<Other column="13" file="/Users/jp/Projects/Alamofire/Source/Alamofire.swift" line="33">
@jpsim
jpsim / testStackOverflow_sahara108.m
Created August 22, 2014 17:14
testStackOverflow_sahara108
- (void)testStackOverflow_sahara108
{
[[RLMRealm defaultRealm] transactionWithBlock:^{
[StringObject createInDefaultRealmWithObject:@[@"a"]];
}];
Class cl = [StringObject class];
NSString *key = @"stringCol";
NSString *value = @"a";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"%K = %@", key, value];
RLMArray *list = [cl objectsWithPredicate:pred];
@jpsim
jpsim / MyTableViewController.m
Created August 19, 2014 22:57
Grouped UITableView using Realm
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
@jpsim
jpsim / LevelDB.m
Last active August 29, 2015 14:04
RealmStringsBenchmarks
#import <Objective-LevelDB/LevelDB.h>
#include <mach/mach_time.h>
#include <stdint.h>
NSString *randomString(NSUInteger length) {
NSMutableString *string = [NSMutableString stringWithCapacity:length];
for (int i = 0; i < length; i++) {
[string appendFormat:@"%C", (unichar)('a' + arc4random_uniform(25))];
}
return string;
@jpsim
jpsim / logs.txt
Created July 11, 2014 18:16
SourceKit Logs in Xcode6-Beta3
sourcekit: [2:sourcekitd_initialize:1299: 0.0003] initializing
2014-07-11 11:12:15.618 Xcode[2028:36673] Failed to connect (abPeoplePickerTemplate) outlet from (IBCocoaStoryboardObjectLibraryAssetProvider) to (IBObjectLibraryAsset): missing setter or instance variable
2014-07-11 11:12:15.627 Xcode[2028:36673] Failed to connect (ikCameraDeviceViewTemplate) outlet from (IBCocoaStoryboardObjectLibraryAssetProvider) to (IBObjectLibraryAsset): missing setter or instance variable
2014-07-11 11:12:15.627 Xcode[2028:36673] Failed to connect (ikDeviceBrowserViewTemplate) outlet from (IBCocoaStoryboardObjectLibraryAssetProvider) to (IBObjectLibraryAsset): missing setter or instance variable
2014-07-11 11:12:15.628 Xcode[2028:36673] Failed to connect (ikImageBrowserViewTemplate) outlet from (IBCocoaStoryboardObjectLibraryAssetProvider) to (IBObjectLibraryAsset): missing setter or instance variable
2014-07-11 11:12:15.628 Xcode[2028:36673] Failed to connect (ikImageViewTemplate) outlet from (IBCocoaStoryboardObjectLibrar
@jpsim
jpsim / JAZMusician.h
Created July 7, 2014 09:25
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.
@jpsim
jpsim / SwiftClassParsing.playground
Last active December 8, 2021 22:23
Swift and Objective-C Class Parsing
////////////////////////////////////////////////
//
// Swift and Objective-C Class Parsing
//
////////////////////////////////////////////////
import Foundation
// Class parsing
  1. Plain Strings (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]*$
  4. Backrefs (201): (...).*\1
  5. Abba (169): ^(.(?!(ll|ss|mm|rr|tt|ff|cc|bb)))*$|^n|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(..+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (198): ^[^o].....?$
  10. Triples (507): (^39|^44)|(^([0369]|([147][0369]*[258])|(([258]|[147][0369]*[147])([0369]*|[258][0369]*[147])([147]|[258][0369]*[258])))*$)
@jpsim
jpsim / NSCFCalendar Error
Created October 18, 2013 18:59
NSCFCalendar Error
-[__NSCFCalendar components:fromDate:]: date cannot be nil
I mean really, what do you think that operation is supposed to mean with a nil date?
An exception has been avoided for now.
A few of these errors are going to be reported with this complaint, then further violations will simply silently do whatever random thing results from the nil.
@jpsim
jpsim / code.m
Last active December 25, 2015 20:39
UIProgressView Always Animates
UIProgressView *v = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
v.frame = CGRectMake(40, 100, 240, 2);
[self.view addSubview:v];
{
double delayInSeconds = 1.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[v setProgress:0.5f animated:NO];
});