Skip to content

Instantly share code, notes, and snippets.

@someoneAnyone
someoneAnyone / GlucoseWithUnitConcentrationMass.swift
Last active March 16, 2021 10:03
Glucose Value Conversion on iOS 10
//: # Glucose Value Conversion on iOS 10.
import Foundation // iOS 10.0, wathOS 3.0, macOS 10.12
/*:
****
## Current Nightscouter Implmentation
- Note: The current app treats glucose values as an aliased Double.
//
// URL Validator.swift
// NightscouterSwiftUI
//
// Created by Peter Ina on 9/15/19.
// Copyright © 2019 Peter Ina. All rights reserved.
//
import Foundation
import Combine
@someoneAnyone
someoneAnyone / NightscouterSiteData.json
Last active June 28, 2019 15:06
JSON Data Format for Nightscouter.
[
{
"url": "https://nscgm.herokuapp.com",
"deviceStatuses": [],
"id": "EB2C30F9-FD8A-4F95-85D5-F65354DF4F8C",
"overrideScreenLock": false,
"configuration": {
"status": "ok",
"settings": {
"alarmUrgentHigh": true,
@someoneAnyone
someoneAnyone / Dictionary+SaveAsPlist.swift
Last active March 2, 2016 16:13
A quick and dirty way of getting dictionary written to the Documents folder for a given app. You can provide a file name or take the default of data. The file name will be appended with ".plist" automatically.
public extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
public func saveAsPlist(fileName: String = "data") -> (successful: Bool, path: NSURL?) {
guard let rootPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first else {
print("No documents directory!")
return (false, nil)
}
let url = NSURL(fileURLWithPath: rootPath)
let plistPathInDocument = url.URLByAppendingPathComponent("\(fileName).plist")
let dict = NSDictionary(objects: self.values.map{ $0 }, forKeys: self.keys.map{ String($0) })
@someoneAnyone
someoneAnyone / NightscoutSocketClient.swift
Last active January 5, 2016 04:55
Using, the following pods... pod 'Socket.IO-Client-Swift', '~> 4.1.6' # Or latest version pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
//
// SocketClient.swift
// NightscouterSocketTest
//
// Created by Peter Ina on 1/4/16.
// Copyright © 2016 Nothingonline. All rights reserved.
//
import Foundation
import Socket_IO_Client_Swift
//
// StickyHeaderLayout.h
// Wombat
//
// Created by Todd Laney on 1/9/13.
// Copyright (c) 2013 ToddLa. All rights reserved.
//
// Modified from http://blog.radi.ws/post/32905838158/sticky-headers-for-uicollectionview-using THANKS!
//
@someoneAnyone
someoneAnyone / complication.swift
Last active November 20, 2015 04:39
some ideas for mapping data for complications
// MARK: - Timeline Population
func getCurrentTimelineEntryForComplication(complication: CLKComplication, withHandler handler: ((CLKComplicationTimelineEntry?) -> Void)) {
// Call the handler with the current timeline entry
#if DEBUG
print(">>> Entering \(__FUNCTION__) <<<")
print("complication family: \(complication.family)")
#endif
@someoneAnyone
someoneAnyone / status.json
Last active August 29, 2015 14:26
Nightscout Status.json Idea
{
"status": "ok",
"version": "0.7.0",
"options": {
"apiEnabled": true,
"careportal": true,
"rawbg": true,
"iob": true
},
"defaults": {
@someoneAnyone
someoneAnyone / entry.json
Last active August 28, 2015 12:45
Model representation of Entries Endpoint for Nightscout. For a given type other properties not relevant would be nil.
[
{
"device": "xDrip",
"type": "sgv",
"dateString": "string",
"date": 0,
"sgv": {
"direction": "string",
"filtered": 0,
"unfiltered": 0,