Skip to content

Instantly share code, notes, and snippets.

- (void)testThatConvertingBackAndForthDoesntAffectResults {
double celsius = 50;
double farenheitResult = [controller convertCelsiusToFarenheit:celsius];
//convert back
double celsiusResult = [controller convertFarenheithToCelsius:farenheitResult];
STAssertEquals(celsius, celsiusResult, @"should be equal");
}
SPEC_BEGIN(TemperatureConverterTests)
describe(@"basic converter", ^{
it(@"converts farenheit To celsius", ^{
ViewController *controller = [ViewController alloc]init];
[[theValue([controller convertCelisusToFarenheit:-40]) should]equal:theValue(-40)];
});
it(@"converts celsius to farenheight", ^{
ViewController *controller = [ViewController alloc]init];
[[theValue([controller convertfarenheitToCelsius:-40]) should]equal:theValue(-40)];
@jpsim
jpsim / .slate
Created March 20, 2013 15:41
.slate
# Fullscreen
bind f:alt;cmd;ctrl move 0;0 screenSizeX;screenSizeY
# Half Screen
bind right:ctrl;cmd push right bar-resize:screenSizeX/2
bind left:ctrl;cmd push left bar-resize:screenSizeX/2
bind up:ctrl;cmd push up bar-resize:screenSizeY/2
bind down:ctrl;cmd push down bar-resize:screenSizeY/2
# Quarter Screen
@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];
});
@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.
  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 / 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
@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 / 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 / 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;