Skip to content

Instantly share code, notes, and snippets.

View nevyn's full-sized avatar

Nevyn Bengtsson nevyn

View GitHub Profile
@nevyn
nevyn / SPLangUndoer.h
Created January 18, 2012 13:09
half-way generalized KVO undoer
#import <Cocoa/Cocoa.h>
#import "SPLangNode.h"
@interface SPLangUndoer : NSObject {
NSUndoManager *mgr;
SPLangNode *root;
}
-(id)initWatchingTree:(SPLangNode*)tree withUndo:(NSUndoManager*)undoManager;
@end
NAME USED AVAIL REFER MOUNTPOINT
fast 10.4G 39.3G 18K /fast
fast/system 10.4G 39.3G 33K /
fast/system/root 1024M 39.3G 1008M legacy
fast/system/tmp 3.67M 39.3G 3.67M /tmp
fast/system/usr 9.33G 39.3G 18K /usr
fast/system/usr/local 5.22G 39.3G 5.22G /usr/local
fast/system/usr/obj 2.60G 39.3G 2.60G /usr/obj
fast/system/usr/ports 1.35G 39.3G 183M /usr/ports
fast/system/usr/ports/distfiles 1.17G 39.3G 1.17G /usr/ports/distfiles
@nevyn
nevyn / awesomepossum
Created September 2, 2011 13:06
finn fem fel
NSDictionary *rootRep = [children objectAtIndex:0];
// Give up gracefully if rep doesn't match reality
if( not [[rootRep objectForKey:@"class"] isEqual:NSStringFromClass([rootController class])])
return self; http://getsetgames.com/wp-content/uploads/2009/07/grab-menu.png
[rootController initWithObjectRepresentation:rootRep];
-(id)init;
...
// sets up some KVO with https://github.com/nevyn/SPSuccinct/blob/master/SPSuccinct/SPDepends.h
$depends(@"audio session", self, @"pause", (id)^{
[selff matchIdleTimer];
});
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(matchIdleTimer) name:UIDeviceBatteryStateDidChangeNotification object:nil];
}
@nevyn
nevyn / foo.m
Created August 5, 2011 20:46
performSelector with number and PODs
//
// hej2AppDelegate.m
// hej2
//
// Created by Joachim Bengtsson on 2011-08-05.
// Copyright 2011 Third Cog Software. All rights reserved.
//
#import "hej2AppDelegate.h"
@nevyn
nevyn / output.txt
Created July 10, 2011 15:44
Output from the SPSuccinct example
2011-07-10 17:42:52.029 SPSuccinct[59337:707] Hello there, (null)
2011-07-10 17:42:52.032 SPSuccinct[59337:707] Hello there, world!
@nevyn
nevyn / gist:1035354
Created June 20, 2011 09:21
nil -[UIViewController navigationController]
(gdb) po [tabController objectAtIndex:1]
<SPNavigationController: 0x4c20a50>
(gdb) po [[tabController objectAtIndex:1] viewControllers]
<__NSArrayI 0x50bb480>(
<SearchViewController: 0x952920>
)
(gdb) po [[[tabController objectAtIndex:1] viewControllers] objectAtIndex:0]
<SearchViewController: 0x952920>
(gdb) po [[[[tabController objectAtIndex:1] viewControllers] objectAtIndex:0] navigationController]
Can't print the description of a NIL object.
@nevyn
nevyn / SPDepends.h
Created June 16, 2011 16:58
Oneliner KVO.
typedef void(^SPDependsCallback)();
/**
* Add a dependency from an object to another object.
* Registers that your object depends on the given objects and their key paths,
* and invokes the callback when the values of any of the given key paths
* changes.
*
* If an owner and association name is given, the dependency object is
* associated with the owner under the given name, and automatically deallocated
@nevyn
nevyn / count.m
Created May 30, 2011 12:12
Count of tracks in playlists in a playlist folder
#import <Foundation/Foundation.h>
@interface PlaylistFolder : NSObject
@property (retain) NSArray *playlists;
-(id)trackCount;
@end
@interface Playlist : NSObject
@property (retain) NSArray *tracks;
@end
@nevyn
nevyn / local_file_plugin_api.h
Created May 13, 2011 03:19
Suggested plugin API for adding file format support to Spotify
#ifndef _SPOTIFY_LOCAL_FILE_PLUGIN_API__H
#define _SPOTIFY_LOCAL_FILE_PLUGIN_API__H
#ifdef __cplusplus
extern "C" {
#endif
/**
Spotify Local File Plugin API