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 / Buzz Fizz
Created November 7, 2011 20:16
Objective C - test 1
#import <Foundation/Foundation.h>
/* Test I had to do, Took me way to long so thought I would draft it up in objective c
basically getting the remainder using the % modular type.
loop through to 100, if number is divisible by 3 print buzz if its divisible by 5 print fizz and if its both print buzz fizz. Else just print the number.
*/
int main(int argc, char *argv[]) {
NSString *string = [NSString alloc] initWithStringFormat:@"%i", 3];
@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")