Skip to content

Instantly share code, notes, and snippets.

View lukeredpath's full-sized avatar
🏠
Working from home

Luke Redpath lukeredpath

🏠
Working from home
View GitHub Profile
@lukeredpath
lukeredpath / roles.rb
Created June 3, 2016 15:44
Defining Pundit policies using role objects
class Role
def can?(ability)
ability_query = "can_#{ability}?"
respond_to?(ability_query) ? __send__(ability_query) : false
end
end
class ManagerRole < Role
def can_manage_users?
true
[07:20:39]: There are no local code signing identities found. You can run `security find-identity -v -p codesigning` to get this output. This Stack Overflow thread has more information: http://stackoverflow.com/q/35390072/774. (Check in Keychain Access for an expired WWDR certificate: http://stackoverflow.com/a/35409835/774 has more info.)
@lukeredpath
lukeredpath / HUDOperation.swift
Created May 19, 2016 16:31
Encapsulating displaying a HUD (and its implementation)
enum HUDAppearanceMode {
case Indeterminate
case IndeterminateWithStatus(status: String)
}
enum HUDDismissalMode {
case Immediately
case WithDelay(delay: NSTimeInterval)
case WithStatus(successStatus: String, failureStatus: String)
}
@lukeredpath
lukeredpath / Test.swift
Last active October 7, 2015 14:30
Protocol defaults?
protocol Search: UISearchResultsUpdating {
func searchFor(query: String)
}
extension Search {
func updateSearchResultsForSearchController(searchController: UISearchController) {
searchFor(searchController.searchBar.text!)
}
}
11/09/2015 16:59:51.434 Interface Builder Cocoa Touch Tool[37987]: assertion failed: 15A282b 13A340: libxpc.dylib + 27704 [9D7FF5E0-5DAA-3118-9A08-436E517037E9]: 0x8d
11/09/2015 16:59:51.436 Interface Builder Cocoa Touch Tool[37987]: assertion failed: 15A282b 13A340: libxpc.dylib + 27704 [9D7FF5E0-5DAA-3118-9A08-436E517037E9]: 0x8d
11/09/2015 16:59:51.437 Interface Builder Cocoa Touch Tool[37987]: assertion failed: 15A282b 13A340: libxpc.dylib + 27704 [9D7FF5E0-5DAA-3118-9A08-436E517037E9]: 0x8d
11/09/2015 16:59:51.439 Interface Builder Cocoa Touch Tool[37987]: assertion failed: 15A282b 13A340: libxpc.dylib + 27704 [9D7FF5E0-5DAA-3118-9A08-436E517037E9]: 0x8d
11/09/2015 16:59:51.522 Interface Builder Cocoa Touch Tool[37987]: assertion failed: 15A282b 13A340: libxpc.dylib + 27704 [9D7FF5E0-5DAA-3118-9A08-436E517037E9]: 0x8d
11/09/2015 16:59:51.525 Interface Builder Cocoa Touch Tool[37987]: assertion failed: 15A282b 13A340: libxpc.dylib + 27704 [9D7FF5E0-5DAA-3118-9A08-436E517037E9]: 0x8d
11/09/2015 16:59:51.52
[NSTimer scheduledTimerWithTimeInterval:self.pollInterval target:self selector:@selector(checkForStatusUpdate) userInfo:nil repeats:YES];
@lukeredpath
lukeredpath / ReactiveLocation.m
Last active August 29, 2015 14:14
Display location on map when authorised
if ([CLLocationManager locationServicesEnabled]) {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
RACSignal *locationAuthorizationStatus = [[RACSignal
concat:@[
[RACSignal return:@([CLLocationManager authorizationStatus])],
[[self rac_signalForSelector:@selector(locationManager:didChangeAuthorizationStatus:) fromProtocol:@protocol(CLLocationManagerDelegate)] map:^id(RACTuple *arguments) {
return arguments.second;
}]
@lukeredpath
lukeredpath / gist:acf6010e0d453f72e6ce
Last active August 29, 2015 14:14
Stuff I've got to get rid of
Stuff for sale:
* Mac Mini 2007 (http://www.everymac.com/systems/apple/mac_mini/specs/mac-mini-core-2-duo-1.83-specs.html) - £40 (TAKEN)
* Onkyo TR-605 (http://www.onkyousa.com/Products/model.php?m=TX-SR605&class=Receiver) - £TBC
Stuff I'm giving away:
* Logitech Squeezebox 2 (TAKEN)
* Logitech Squeezebox Boom (TAKEN)
* Behringer V-Amp (http://www.behringer.com/EN/Products/V-AMP.aspx)
Thank you for contacting us again on 15 January 2015 regarding red light jumping at Bow Roundabout. I am sorry the problem persists at this location.
We are currently investigating this matter and will contact you again when we have information for you.
[self.window makeKeyAndVisible];
//[self presentMyNormalModalViewController];
UIViewController *testVC = [[UIViewController alloc] init];
testVC.view.backgroundColor = [UIColor redColor];
[self.window.rootViewController presentViewController:testVC animated:NO completion:nil];