Skip to content

Instantly share code, notes, and snippets.

View nevyn's full-sized avatar

Nevyn Bengtsson nevyn

View GitHub Profile
@nevyn
nevyn / UIImage+getPixels.m
Created May 15, 2010 19:12
Get the pixels of an UIImage
@implementation UIImage (BCGetPixels)
-(void)bc_getPixels:(char*)pixels;
{
CGImageRef imageRef = self.CGImage;
NSUInteger width = CGImageGetWidth(imageRef);
NSUInteger height = CGImageGetHeight(imageRef);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
NSUInteger bytesPerPixel = 1;
#!/usr/bin/env macruby
Dir["*.plist"].each { |f|
d = NSDictionary.dictionaryWithContentsOfFile(f)
cr = d["description"]
cr.writeToFile(f+".crash", atomically:false)
}
# Could probably use ARGF too
@nevyn
nevyn / NSObject+SPInvocationGrabbing.h
Created August 6, 2010 11:14
Spotify's invocation grabber, with some magic tricks
#import <Foundation/Foundation.h>
@interface SPInvocationGrabber : NSObject {
id _object;
NSInvocation *_invocation;
int frameCount;
char **frameStrings;
BOOL backgroundAfterForward;
BOOL onMainAfterForward;
BOOL waitUntilDone;
#!/usr/bin/env ruby
def method_missing(*stuff)
`#{stuff.join " "}`
end
def ll *a; ls "-la", *a end
puts ll dirname which "ls"
@nevyn
nevyn / README.md
Created August 26, 2010 08:27
LinkMap symbolicator

If you have an ldmap/LinkMap file and a crash report, you can use this utility to symbolicate the crash report. It's not at all optimized... You need to replace INSERT_BUNDLE_IDENTIFIER_HERE with the identifier of your app (com.yourcompany.yourapp); it's what it uses to determine what symbols might be missing and should be looked up.

@nevyn
nevyn / SPBindings.h
Created September 8, 2010 16:30
Bindings for iOS
#import <Foundation/Foundation.h>
@interface NSObject (SPBindings)
-(void)sp_bind:(NSString*)binding toObject:(id)observable withKeyPath:(NSString*)observableKeyPath;
-(void)sp_unbind:(NSString*)binding;
@end
@nevyn
nevyn / README.md
Created January 4, 2011 08:37
SPMediaKeyTap is a global event tap for the play/pause, prev and next keys on the keyboard. http://overooped.com/post/2593597587/mediakeys
@nevyn
nevyn / unreadgraph.rb
Created January 6, 2011 14:46
Get unread and flag count in inbox. Drives http://nevyn.nu/unreads/. Good indicator of how stressed I am.
#!/usr/bin/env ruby
require 'net/imap'
require 'rubygems'
require 'sqlite3'
imap = Net::IMAP.new("imap.gmail.com", 993, true)
imap.login("someusername", "somepassword")
imap.select('INBOX')
total = imap.responses["EXISTS"][-1]
unread = imap.search(["UNSEEN"]).length
How do you store a JS function ref in a cocoa webkit plugin, that you can later call as a callback?
How do you properly draw on the title bar?
@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