Skip to content

Instantly share code, notes, and snippets.

View brianmpalma's full-sized avatar

Brian M. Palma brianmpalma

View GitHub Profile
@brianmpalma
brianmpalma / Git patch
Created May 26, 2014 19:03
How to select lines 5 - 10?
# Manual hunk edit mode -- see bottom for a quick guide
@@ -184,5 +184,10 @@
return cls.build_game_base_url(gid) + 'plays.xml'
@classmethod
- def build_inning_x_url(cls, gid, inning_number):
+ def build_inning_url(cls, gid):
+ """Returns URL for inning directory"""
+ return cls.build_game_base_url(gid) + 'inning/'
+
@brianmpalma
brianmpalma / NSKeyValueCoding Overview
Created February 10, 2015 17:56
NSKeyValueCoding Informal Protocol
# NSKeyValueCoding
An informal protocol on NSObject. It provides an indirect way of setting values by key (property / iVar name) without using accessors or iVar access.
## Getting Values
```
- valueForKey:
- valueForKeyPath:
- dictionaryWithValuesForKeys:
@brianmpalma
brianmpalma / VC initialization
Created March 23, 2015 18:55
VC initialization
// no new initializers defined in the .h
- (instancetype)init
{
self = [super initWithNibName:nil bundle:nil];
if (self) {
// do stuff
}
@brianmpalma
brianmpalma / Borderable.swift
Last active February 22, 2016 00:42
Protocol + extension for UIView and friends that adds bordering capabilities in IB using IBDesignable and IBInspectable
import UIKit
protocol Borderable {
var cornerRadius: CGFloat { get set }
var borderWidth: CGFloat { get set }
var borderColor: UIColor? { get set }
}
@IBDesignable
extension UIView: Borderable {
extension Bool {
mutating func toggle() {
self = !self
}
}
var isExpanded: Bool = false
isExpanded.toggle()
@brianmpalma
brianmpalma / BMPAudioFilePlayerPlugIn.h
Last active April 2, 2016 21:21
Minimal Quartz Composer Audio Player Plug In using AVAudioPlayer
#import <Quartz/Quartz.h>
@interface BMPAudioFilePlayerPlugIn : QCPlugIn
@property (nonatomic, copy) NSString *inputFilePath;
@end
#import "BMPAudioFilePlayerPlugIn.h"
#import <AVFoundation/AVFoundation.h>
- (void)loadWindow
{
var success = [CPBundle loadCibNamed:@"AddPlayer" owner:self];
_window = [[CPWindow alloc] initWithContentRect:[_addPlayerContentView bounds]
styleMask:CPDocModalWindowMask];
[_window setContentView:_addPlayerContentView];
}