Skip to content

Instantly share code, notes, and snippets.

View zoul's full-sized avatar

Tomáš Znamenáček zoul

View GitHub Profile
@zoul
zoul / OSStatus.m
Created October 19, 2010 08:21
Decode OSStatus error codes into strings.
NSString *NSStringFromOSStatus(OSStatus errCode)
{
if (errCode == noErr)
return @"noErr";
char message[5] = {0};
*(UInt32*) message = CFSwapInt32HostToBig(errCode);
return [NSString stringWithCString:message encoding:NSASCIIStringEncoding];
}
@zoul
zoul / AVAssetExportSession+Testing.m
Created November 8, 2010 08:35
Export assets synchronously. Good for testing.
@implementation AVAssetExportSession (Testing)
- (void) exportSynchronously
{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[self exportAsynchronouslyWithCompletionHandler:^{
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);
@zoul
zoul / DetectDeallocations.h
Created November 11, 2010 15:33
Detects object deallocations. Good for testing.
// Runs given block. Returns YES if some object of class ‘c’
// was deallocated in the block. Not thread-safe.
BOOL classGetsDeallocated(Class c, void (^block)(void));
// Convenience interface that calls the function above.
// Releases object, returns YES if object was deallocated.
BOOL getsDeallocatedByReleasing(id object);
@zoul
zoul / Foo.h
Created January 5, 2011 14:24
Synthesized properties in Objective-C without instance variables
@interface Foo : NSObject {}
@property(assign) float foo;
@end
@zoul
zoul / proxy.pl
Created November 15, 2011 18:41
Simple debugging HTTP proxy in Perl
#!/usr/bin/env perl
use Modern::Perl;
use HTTP::Proxy;
use HTTP::Proxy::HeaderFilter::simple;
my $proxy = HTTP::Proxy->new(host => undef, port => 3128);
my $filter = HTTP::Proxy::HeaderFilter::simple->new(sub
{
my ($self, $headers, $message) = @_;
@zoul
zoul / Foo.m
Created November 16, 2011 10:04
IBOutlets in private interfaces
#import "Foo.h"
// Private Foo interface. The IBOutlet will get picked up by Interface Builder!
@interface Foo ()
@property(strong) IBOutlet UIView *someView;
@end
@implementation Foo
@synthesize someView;
@zoul
zoul / build-notifier.rb
Last active May 17, 2018 15:21
Posts a message to the OS X notification center when a Jekyll build is finished. Requires TerminalNotifier, see http://git.io/5X99Eg or “gem install terminal-notifier”.
begin
require 'terminal-notifier'
module Jekyll
class Site
alias jekyll_process process
def process
jekyll_process
TerminalNotifier.notify('Jekyll rebuild finished.')
end
end
@zoul
zoul / bot-build-upload.sh
Last active August 29, 2015 14:16
Upload a HockeyApp version from an Xcode Continuous Integration Bot, iOS version
# Based on http://hack.swic.name/automated-xcode-6-bot-testflight-uploads/
API_TOKEN="XXX"
APP_ID="XXX"
upload() {
BASE_PATH="/Library/Developer/XcodeServer/IntegrationAssets/"
IPA="${BASE_PATH}${XCS_BOT_ID}-${XCS_BOT_NAME}/${XCS_INTEGRATION_NUMBER}/${XCS_BOT_NAME}.ipa"
ARCHIVE="${BASE_PATH}${XCS_BOT_ID}-${XCS_BOT_NAME}/${XCS_INTEGRATION_NUMBER}/Archive.xcarchive.zip"
DSYM_ZIP="/tmp/dSYM.zip"
@zoul
zoul / bot-build-upload-mac.sh
Last active August 29, 2015 14:16
Upload a HockeyApp version from an Xcode Continuous Integration Bot, Mac version
# Based on http://hack.swic.name/automated-xcode-6-bot-testflight-uploads/
API_TOKEN="XXX"
APP_ID="XXX"
upload() {
BASE_PATH="/Library/Developer/XcodeServer/IntegrationAssets/"
ARCHIVE="${BASE_PATH}${XCS_BOT_ID}-${XCS_BOT_NAME}/${XCS_INTEGRATION_NUMBER}/Archive.xcarchive.zip"
APP_ZIP="/tmp/app.zip"
DSYM_ZIP="/tmp/dSYM.zip"
@zoul
zoul / immutable-tree.pl
Created March 17, 2015 18:02
Building an immutable tree
#!/usr/bin/env perl
use v5.14;
use strict;
use warnings;
use Data::Dump 'pp';
{
package Node;
use Mouse;