Skip to content

Instantly share code, notes, and snippets.

View nevyn's full-sized avatar

Nevyn Bengtsson nevyn

View GitHub Profile
@omz
omz / Add Web Tab.py
Last active December 3, 2023 23:33 — forked from steventroughtonsmith/Add Web Tab.py
Insert a custom browser tab into Pythonista
# coding: utf-8
from objc_util import *
import console
import urllib
import dialogs
WKWebView = ObjCClass('WKWebView')
UIViewController = ObjCClass('UIViewController')
UIBarButtonItem = ObjCClass('UIBarButtonItem')
NSURLRequest = ObjCClass('NSURLRequest')
@nevyn
nevyn / ExampleUsage.m
Created June 3, 2012 23:36 — forked from anonymous/ExampleUsage.m
Testing RAC by writing a socket abstraction on top of it with AsyncSocket
[[[TCRACSocket connectTo:@"localhost" port:1236] selectMany:^id<RACSubscribable>(id x) {
return [x lines];
}] subscribeNext:^(id x) {
self.text.text = x;
} error:^(NSError *error) {
NSLog(@"Failure: %@", error);
exit(0);
}];
@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 / 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 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 / 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;
@nevyn
nevyn / TollFreeBridgedCpp.mm
Created April 8, 2010 21:58
Transparent ObjC<>C++ bridge
/*
Say you have a largeish C++ class. You want to use it from ObjC. ObjC++ is painful;
C++ is painful. .mm files are bad. How about if we could just treat that C++
object as an ObjC object whenever it exits C++ land?
Apple already solved this problem once with toll free bridging. The tricky part is
vtables -- with a vtable, isa isn't at offset 0 of the memory layout of the object.
The code below is a work in progress to work around this.
*/
@nevyn
nevyn / wave.rb
Created July 22, 2009 15:38
Google wave ASCII art
#!/usr/bin/env ruby
# http://gist.github.com/152050
# thanks http://www.ascii-art.de/ascii/uvw/wave.txt
class Sprite
attr_accessor :data, :w, :h
def initialize w = 80, h = 23
@w = w
@h = h