Skip to content

Instantly share code, notes, and snippets.

View robnadin's full-sized avatar

Rob Nadin robnadin

  • Dyson
  • Bristol, UK
  • 17:56 (UTC +01:00)
  • X @robnadin
View GitHub Profile
Pod::Spec.new do |s|
s.name = 'BLEFramework'
s.version = '1.4'
s.summary = 'The Buzz Flashing Glassware framework allows you to activate your Buzz Celebration Drinkware from your mobile device.'
s.homepage = 'http://www.buzzproducts.com/flashingcup/'
s.author = { 'Buzz Products' => '[email protected]' }
s.source = { :path => 'BLEFramework' }
s.social_media_url = 'https://twitter.com/buzzproducts'
s.ios.deployment_target = '8.0'
extension NSUUID {
static var zero: NSUUID {
var bytes = [UInt8](count: 16, repeatedValue: 0)
return NSUUID(UUIDBytes: &bytes)
}
}
import UIKit
extension UIResponder {
private weak static var _currentFirstResponder: UIResponder?
static var currentFirstResponder: UIResponder? {
get {
_currentFirstResponder = nil
UIApplication.sharedApplication().sendAction(#selector(findFirstResponder), to: nil, from: nil, forEvent: nil)
@robnadin
robnadin / Optional+BooleanType.swift
Created March 23, 2016 16:06
Ternary operator support for optionals
extension Optional: BooleanType {
public var boolValue: Bool {
switch self {
case .Some(let value) where !(value is Bool):
return true
case .Some(let value as Bool) where value:
return true
default:
return false
@robnadin
robnadin / NSDate+ISO8601.swift
Created March 8, 2016 16:44
Fast C-based ISO8601 date parser written in Swift
import Foundation
extension NSDate {
class func dateFromISO8601String(string: String?) -> NSDate? {
guard let string = string else {
return nil
}
var tm = Darwin.tm()
@robnadin
robnadin / NSAttributedString+HTMLStyle.h
Last active May 29, 2019 04:56
NSAttributedString-HTMLStyle
//
// NSAttributedString+HTMLStyle.h
// QRContentMobilizer
//
// Created by Wojciech Czekalski on 22.03.2014.
// Copyright (c) 2014 Wojciech Czekalski. All rights reserved.
//
#import <Foundation/Foundation.h>
extension UINavigationController {
func pushViewController(_ viewController: UIViewController, animated: Bool, completionHandler: (() -> Void)?) {
pushViewController(viewController, animated: animated)
viewController.transitionCoordinator.animate(alongsideTransition: nil) { _ in
completionHandler?()
}
}
}
@robnadin
robnadin / Brightness.swift
Last active January 22, 2016 11:36
Set brightness based on hour
/* Brightness.swift -- Set brightness based on hour
This file is part of brightness.
Brightness is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Brightness is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@robnadin
robnadin / Array+Operators.swift
Last active January 8, 2016 15:52
Custom Swift operators to handle array contents
//
// Array+Operators.swift
//
//
// Created by Rob Nadin on 08/01/2016.
// Copyright © 2016 Rob Nadin. All rights reserved.
//
import Foundation

NSDecimalNumber Integer Fix

So given the decimal 109268.27107118553088 the result is:

32-bit architecture

integer: 0
int: 109268
uint: 109268
unsigned integer: 0