Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

import Foundation
extension Date{
// Calculates the progress made from the start of the given range to the current date
// Returns a percentage value between 0 and 100
func getProgress(range: ClosedRange<Date>) -> Double {
if (self >= range.upperBound ) {
return 100
} else if (self <= range.lowerBound) {
return 0
@dynamicMemberLookup
class QueuedPropertyAccess<U:AnyObject>{
weak var anObj : U?
weak var dispatchQueue: DispatchQueue!
init(_ anObj:U, dispatchQueue:DispatchQueue) {
self.anObj = anObj
self.dispatchQueue = dispatchQueue
}
subscript<T>(dynamicMember keyPath: KeyPath<U, T>) -> T {
//
// These are the default values used for AlgorithmRunner.RunAlgorithm
//
// This is the default state. If you scan the sensor during the first hour of warmup, this is what will be returned by dataprocessingnative.getNewState(internal function provided by abbot)
// This also means that every call to the libreoopalgo acts like it's the first time scanning the sensor
// if you want to behave in a "proper" way, you should always save the newState after a scan and feed that as oldState to the next run of AlgorithmRunner.RunAlgorithm
// An obvious exception to this, is when changing sensors. When changing sensors, you should feed the algo with null (which is the same as feeding it with the oldState1 below)
2017-09-22 17:25:02.191031+0200 Loop[1993:362317] [MC] Lazy loading NSBundle MobileCoreServices.framework
2017-09-22 17:25:02.195433+0200 Loop[1993:362317] [MC] Loaded MobileCoreServices.framework
2017-09-22 17:25:02.203954+0200 Loop[1993:362317] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-09-22 17:25:02.909236+0200 Loop[1993:362317] [MC] Reading from public effective user settings.
2017-09-22 17:25:02.966539+0200 Loop[1993:362317] Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 6604681404063684191_Portrait_iPhone-Simple-Pad_Default
2017-09-22 17:25:03.007086+0200 Loop[1993:362317] Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 6604681404063684191_Portrait_iPhone-Simple-Pad_Default
2017-09-22 17:25:03.069203+0200 Loop[1993:362317] [AnalyticsManager] (
(
"Bolus Screen [:]"
)
API_SECRET="somelongsecret"
URL="foo.herokuapp.com"
NOW=$(date +%s%N | cut -b1-13)
read -d '' json << FOO
{
"sgv": 55,
"type": "sgv",
"direction": "Flat",
"date": $NOW