Skip to content

Instantly share code, notes, and snippets.

@mschulkind
mschulkind / gist:942829
Created April 26, 2011 18:42
ERB output
defaults: &defaults
host: localhost
persist_in_safe_mode: true
# slaves:
# - host: slave1.local
# port: 27018
# - host: slave2.local
# port: 27019
development:
Note that there are some tricks to make special keys work and escape CSI bytes
in the text. The |:map| command also does this, thus you must avoid that it
is done twice. This does not work: >
:imap <expr> <F3> "<Char-0x611B>"
Because the <Char- sequence is escaped for being a |:imap| argument and then
again for using <expr>. This does work: >
:imap <expr> <F3> "\u611B"
Using 0x80 as a single byte before other text does not work, it will be seen
as a special key.
function! ScreenMovement(movement)
if exists("b:physical_line_mode") && b:physical_line_mode && &wrap
return "g" . a:movement
else
return a:movement
endif
endfunction
function! InsertModeScreenMovement(movement)
if &filetype != "fuf"
i <C-R> * "\<C-G>u\<C-R>".nr2char(getchar())."\<C-G>u"
i <C-R><Tab> * <C-R>=ShowAvailableSnips()<CR>
@mschulkind
mschulkind / gist:1143324
Created August 13, 2011 00:27
async image loading
// imageView is a UIImageView
NSURL* imageNSURL = [NSURL URLWithString:value];
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
NSData* imageData = [[NSData alloc] initWithContentsOfURL:imageNSURL];
dispatch_async(
dispatch_get_main_queue(),
^{
[DEBUG] 2011-08-16 19:13:51.691 foo-app[65967:207] Exception - sourceID: 98712768
Source:
shouldRotateToOrientation(0);
Offending line:
1: shouldRotateToOrientation(0);
Call stack:
(null)
(null)
// Start building the command object.
var command = {
className: service,
methodName: action,
arguments: []
};
// Register the callbacks and add the callbackId to the positional
// arguments if given.
var callbackId = null;
#import <UIKit/UIKit.h>
@interface DebugUIWebView : UIWebView {
@private
NSMutableDictionary* sourceIDMap_;
}
@property (nonatomic, retain) NSMutableDictionary* sourceIDMap;
@end
Class superclass = class_getSuperclass([self class]);
Method superDealloc = class_getInstanceMethod(superclass, _cmd);
IMP superDeallocImp = method_getImplementation(superDealloc);
superDeallocImp(self, _cmd);
@mschulkind
mschulkind / gist:1217885
Created September 14, 2011 21:43
ObjC Swizzlin'
// Every class using this inherits from the class defining these methods,
// and provides a +uiKitSubclass method which returns the class object of
// the class which should be swizzled.
+ (void)subclassMethod:(SEL)selector
withImplementation:(IMP)subclassedImplementation
{
Method uiKitMethod = class_getInstanceMethod([self uiKitSubclass], selector);
assert(uiKitMethod);