Skip to content

Instantly share code, notes, and snippets.

View odrobnik's full-sized avatar

Oliver Drobnik odrobnik

View GitHub Profile
@odrobnik
odrobnik / gist:6695920
Created September 25, 2013 06:42
iOS 7 power assertion crash
Incident Identifier: 1C50164A-D012-469B-A5E4-675164AD4AC8
CrashReporter Key: 10d06614c22e25053f76586bd110cdfa0ced43f0
Date: 2013-09-25 07:48:20 +0200
OS Version: iPhone OS 7.0 (11A465)
mediaserverd: com.apple.audio.AudioSession-136(com.apple.podcasts).isplaying NoIdleSleepAssertion == 255, held for 00:16:43
mediaserverd: com.apple.audio.VAD Aggregate Device UID 2.isrunning NoIdleSleepAssertion == 255, held for 00:17:01
SpringBoard: com.apple.springboard.idle NoIdleSleepAssertion == 255, held for 00:01:44
backboardd: MobileSafari[142]-com.apple.mobilesafari.AppSuspensionMemoryCleanupTask [0x16d30800]/com.apple.mobilesafari.TabDocumentResourceLoadTask [0x16d31230] NoIdleSleepAssertion == 255, held for 00:01:36
backboardd: Podcasts[136]-Called by iTunesStoreUI, from <redacted> [0x16e59330]/com.apple.storebookkeeper-Podcasts-<IMAsynchronousTask: 0x192d7ab0> 'MZUPPStore Synchronize' [0x16d51660]/136 [0x16d32e20]/com.apple.StoreServices.SSSQLiteDatabase [0x16e4bf10] NoIdleSleepAssertion
@implementation DTProgressReportingURLProtocol
{
NSURLConnection *_connection;
dispatch_semaphore_t _semaphore;
}
+ (BOOL)canInitWithRequest:(NSURLRequest *)request
{
NSLog(@"%@", [self propertyForKey:@"UserAgentSet" inRequest:request]);
@odrobnik
odrobnik / gist:6421605
Created September 3, 2013 09:26
Why does setting the diameter cause the size to go to {0,0}?
@implementation ExpandButton
{
NSLayoutConstraint *_widthConstraint;
}
- (id)initWithFrame:(CGRect)frame
{
CGFloat smallerDim = MIN(frame.size.height, frame.size.width);
self = [super initWithFrame:frame];
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
CGFloat topInset = 0;
CGFloat bottomInset = 0;
if ([self respondsToSelector:NSSelectorFromString(@"topLayoutGuide")])
{
id topLayoutGuide = [self valueForKeyPath:@"topLayoutGuide"];
(lldb) po [self.view recursiveDescription]
<UIScrollView: 0x8b96320; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x8b990c0>; layer = <CALayer: 0x8b96530>; contentOffset: {0, 0}>
| <_UILayoutGuide: 0x8b96720; frame = (0 0; 0 20); hidden = YES; layer = <CALayer: 0x8b96790>>
| <_UILayoutGuide: 0x8b96ac0; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x8b96b30>>
| <UIImageView: 0x8b98b70; frame = (316.5 561; 3.5 7); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x8b98c50>>
| <UIImageView: 0x8b98330; frame = (313 564.5; 7 3.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x8b986c0>>
| <ContentView: 0x8b99eb0; frame = (0 0; 2000 2000); layer = <DTTiledLayerWithoutFade: 0x8b95c80>>
(lldb) po self.view.constraints
<__NSArrayM 0x8a67630>(
<_UILayoutSupportConstraint:0x8b96f10 V:[_UILayoutGuide:0x8b96720(20)]>,
@odrobnik
odrobnik / BCKEAN13Code.m
Last active December 20, 2015 20:49
First progress on making a modern EAN13 Barcode generator ...
//
// BCKEAN13Code.m
// BarCodeKit
//
// Created by Oliver Drobnik on 8/9/13.
// Copyright (c) 2013 Oliver Drobnik. All rights reserved.
//
#import "BCKEAN13Code.h"
@odrobnik
odrobnik / AppDelegate.m
Created August 7, 2013 13:35
replacing HTML entities with libxml2's SAX HTML Parser
#import "AppDelegate.h"
#import "ViewController.h"
#import "DTHTMLParser.h"
@interface AppDelegate () <DTHTMLParserDelegate>
@end
@implementation AppDelegate
@odrobnik
odrobnik / gist:5712761
Created June 5, 2013 09:34
Which to prefer?
- (CGSize)sizeThatFits:(CGSize)size
{
CGSize neededSize = [self intrinsicContentSize]; // creates layout frame if necessary
if (neededSize.width>=0 && neededSize.height>=0)
{
return neededSize;
}
// 1
@odrobnik
odrobnik / gist:5705353
Last active December 18, 2015 01:39
BOOL test
// test if there is a byte trunction happening
for (int i=0; i<32; i++)
{
__unsafe_unretained id pointer = (__bridge id)(void *)(1<<i);
NSUInteger v = (int)pointer;
if (pointer)
{
@odrobnik
odrobnik / DTWeakSupport.h
Created June 3, 2013 09:54
using weak where possible ...
#import <Availability.h>
#if __has_feature(objc_arc_weak)
#define DT_WEAK_IVAR_IF_SUPPORTED __weak
#define DT_WEAK_PROPERTY_IF_SUPPORTED weak
#elif __has_feature(objc_arc)
#define DT_WEAK_IVAR_IF_SUPPORTED __unsafe_unretained
#define DT_WEAK_PROPERTY_IF_SUPPORTED assign
#endif