Skip to content

Instantly share code, notes, and snippets.

@aufflick
aufflick / gist:2420113
Created April 19, 2012 10:18
Turns out you can add methods to the block classes
void foo(id self, SEL _cmd);
void foo(id self, SEL _cmd)
{
NSLog(@"foo");
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString * flubber = @"flubber";
void (^barGlobal)(void) = ^{ NSLog(@"bar"); };
@aufflick
aufflick / bot2.pl
Created April 19, 2011 02:32
Quick hack to provide bot access to IRC history logs
#!/opt/bin/perl -w
package IRC::Bot2;
use strict;
use warnings;
use Moose;
extends 'IRC::Bot';
use IRC::Bot::Log::Extended;
@aufflick
aufflick / emacs-pipe.pl
Last active February 9, 2018 23:44
Piping to an emacs buffer with emacsclient
#!/usr/bin/env perl
# You can use this script in a pipe. It's input will become an emacs buffer
# via emacsclient (so you need server-start etc.)
# See http://mark.aufflick.com/o/886457 for more information
# Copyright (C) 2011 by Mark Aufflick <mark@aufflick.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
gen/wxe_events.cpp: In function 'void initEventTable()':
gen/wxe_events.cpp:277: error: 'wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN' was not declared in this scope
gen/wxe_events.cpp:278: error: 'wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP' was not declared in this scope
gen/wxe_events.cpp:279: error: 'wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN' was not declared in this scope
gen/wxe_events.cpp:280: error: 'wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP' was not declared in this scope
gen/wxe_events.cpp:281: error: 'wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED' was not declared in this scope
gen/wxe_events.cpp:282: error: 'wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE' was not declared in this scope
gen/wxe_events.cpp:283: error: 'wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK' was not declared in this scope
make[3]: *** [i386-apple-darwin9.8.0/wxe_events.o] Error 1
release: NSInvocation
autorelease: UINavigationItem
release: GHUnitIPhoneViewController
autorelease: UINavigationButton
release: NSInvocation
autorelease: UINavigationItem
release: NSMethodSignature
autorelease: NSCFString
release: NSThread
#0 0x90f4ced7 in objc_msgSend
#1 0x03d25400 in ??
#2 0x00002754 in -[CJTestCJCard testBInsert] at CJTestCJCard.m:91
#3 0x0000dfc2 in +[GHTesting runTestWithTarget:selector:exception:
interval:reraiseExceptions:] at GHTesting.m:245
#4 0x0000e6fd in -[GHTest run:] at GHTest.m:205
#5 0x0000fbec in -[GHTestGroup _run:] at GHTestGroup.m:304
#6 0x0000fbec in -[GHTestGroup _run:] at GHTestGroup.m:304
#7 0x0001199b in -[GHTestRunner runTests] at GHTestRunner.m:132
#8 0x000115c9 in -[GHTestRunner _runInBackground] at GHTestRunner.m:150
@implementation CJTestCJCard
- (void)setUpClass {
// swap the release implementations
Method releaseMethod = class_getInstanceMethod([NSObject class],
@selector(release));
Method releaseLogMethod = class_getInstanceMethod([NSObject class],
@selector(releaseLog));
IMP origReleaseImp = method_setImplementation(releaseMethod,
#import <objc/objc-class.h>
@implementation NSObject (override)
- (void) releaseLog
{
fprintf(stderr, "release: %s\n", class_getName([self class]));
// now call the original implementation (swapped with releaseLog)
// to actually effect the release
[self releaseLog];
- (void) testBInsert
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
for (int i=0 ; i < 10 ; i++) {
CJCard *card = [[CJCard alloc] init];
card.name = [NSString stringWithFormat:@"card %d", i];
card.type = CJCARD_OTHER_STRING;
[card commit];
[card release];