Simple visual illustrations of how CGRectDivideWithPadding works.
+-------+---------+------------>
e | | |
d | slice | padding | remainder…
g | | |
e | | |
Copyright 2015 Chris Eidhof | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE |
#if DEBUG | |
/** | |
Toggles assertion of Core Data managed object contexts. Only available when DEBUG is defined. | |
When enabled, your application will throw an exception when accessing or modifying entities in a context other than their own. | |
*/ | |
void TCBToggleAssertingContextQueues(); | |
#endif |
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale) | |
{ | |
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale); | |
} | |
CGRect CGRectIntegralScaled(CGRect rect) | |
{ | |
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]); | |
} |
Simple visual illustrations of how CGRectDivideWithPadding works.
+-------+---------+------------>
e | | |
d | slice | padding | remainder…
g | | |
e | | |
#import <Foundation/Foundation.h> | |
@interface NSLocale (jr_displaysAMPM) | |
+ (BOOL)jr_currentLocaleDisplaysAMPM; | |
- (BOOL)jr_displaysAMPM; | |
@end |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
NSString *safe = self.keys.url.port.stringValue; | |
NSString *unsafe = @"url.port.stringValue"; | |
assert([safe isEqualToString:unsafe]); |
// | |
// NSFileManager+BKExtensions.h | |
// BlocksKit | |
// | |
// Created by Steve Streza on 10/3/10. | |
// Copyright 2010 Steve Streza. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This morning I discovered a nasty little problem with git-rebase that can have pretty unexpected and unwanted results - how it handles a merge commit.
The TL;DR version is this: Always use git rebase -p
I think a lot of people are using git pull --rebase
as their default to avoid unnecessary merge commits when fetching the latest code from master. There are a few blog posts on the matter, such as [1] [2]
// | |
// NSObject+BlockObservation.h | |
// Version 1.0 | |
// | |
// Andy Matuschak | |
// [email protected] | |
// Public domain because I love you. Let me know how you use it. | |
// | |
#import <Cocoa/Cocoa.h> |