Skip to content

Instantly share code, notes, and snippets.

View scottmkroberts's full-sized avatar

Scott Roberts scottmkroberts

  • Advance Labs
  • Peterborough, UK
View GitHub Profile
@scottmkroberts
scottmkroberts / week3.md
Created February 17, 2017 08:04
UCP-WEEK-3

#Week 3 - Foundation

Foundation Website Web Frameworks.


Last week we covered over bootstrap and some mobile design patterns, this week will cover Foundation framework and how we can use that.

What this lesson will cover

@scottmkroberts
scottmkroberts / facebook2.m
Last active November 25, 2016 23:23
Facebook auto check
/**
*The following mimics thefunctionality of showDialog in how to call the function but instead of using the method
* to know what dialog to show we use the passed method name to check for that permssion e.g. "email".
*/
// In www/facebook-native.js
exports.checkHasCorrectPermissions = function checkHasCorrectPermissions (s, f) {
exec(s, f, 'FacebookConnectPlugin', 'checkHasCorrectPermissions', [])
}
@scottmkroberts
scottmkroberts / facebook.m
Last active November 25, 2016 23:13
ionic FacebookConnectPlugin Addition
/**
*The following mimics thefunctionality of showDialog in how to call the function but instead of using the method
* to know what dialog to show we use the passed method name to check for that permssion e.g. "email".
*/
// In www/facebook-native.js
exports.checkPermissions = function checkPermissions (options, s, f) {
exec(s, f, 'FacebookConnectPlugin', 'checkPermissions', [options])
}
@scottmkroberts
scottmkroberts / money
Created November 27, 2014 19:40
UK Currency
// Playground - noun: a place where people can play
import UIKit
let numberFormatter = NSNumberFormatter()
numberFormatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
numberFormatter.formatterBehavior = NSNumberFormatterBehavior.Behavior10_4
numberFormatter.currencyCode = "GBP"
numberFormatter.generatesDecimalNumbers = true
numberFormatter.locale = NSLocale(localeIdentifier: "en_UK")
@scottmkroberts
scottmkroberts / HealthKitFormatter
Created July 25, 2014 15:56
Part of my HealthKitFormatter Class
//
// HealthKitFormatter.m
// HealthKitExample
//
// Created by Scott Roberts on 24/07/2014.
// Copyright (c) 2014 Scottr. All rights reserved.
//
#import "HealthKitFormatter.h"
@scottmkroberts
scottmkroberts / AuthChecks
Last active August 29, 2015 14:04
checkAuthorisationForCharacteristicType
-(BOOL)checkAuthorisationForCharacteristicType:(HKCharacteristicType *)characteristicType{
HKAuthorizationStatus authStatus = [self.store authorizationStatusForType:characteristicType];
if(authStatus == HKAuthorizationStatusSharingAuthorized){
return YES;
}else{
return NO;
}
@scottmkroberts
scottmkroberts / fizzBuzz
Last active August 29, 2015 14:02
Fizz Buzz in Siwft
for i in 1...100{
let divisbleBy3 = i%3
let divisbleBy5 = i%5
if divisbleBy3 == 0 && divisbleBy5 == 0{ // no remainder
println("fizz buzz")
}else if divisbleBy3 == 0{
println("fizz")
}else if divisbleBy5 == 0{
println("buzz")
@scottmkroberts
scottmkroberts / bugFix
Created September 20, 2013 10:52
Fix issue with managedObjectContextDidSave notification.
/* Can be called from any thread */
- (void)managedObjectContextDidSave:(NSNotification *)note
{
// FIX: you must mergeChangesFromContextDidSaveNotification: on main thread
// handling the notification occurs on background thread.
// it needs to "merge" on the main thread.
// From: http://benford.me/blog/2012/5/7/an-observer-of-nsmanagedobjectcontextdidsavenotification-html
NSManagedObjectContext *context = (NSManagedObjectContext *)note.object;
if( context.persistentStoreCoordinator == managedObjectContext.persistentStoreCoordinator ){
@scottmkroberts
scottmkroberts / SegueSnippet
Created February 21, 2013 19:20
Pushing Segue Snippet
[self performSegueWithIdentifier:@"id" sender:self];
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"id"]) {
// Do stuff.
}
}
@scottmkroberts
scottmkroberts / CoreDataDefaultCodeSnippet
Last active December 14, 2015 00:39
Core Data Code (for when I quickly want to manually add Core Data to a project)
//-- NOTE: Do not forget to add Framework
//-- Extra Header Code
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
- (void)saveContext;