This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getOSVerProfile() throws -> OSVersionRequirement? { | |
if Utils().demoModeEnabled() { | |
return nil | |
} | |
guard | |
let osRequirements = nudgeDefaults.object(forKey: "osVersionRequirements") as? [[String:AnyObject]] | |
else { | |
// Log missing key in nudgeDefaults | |
return nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>PayloadContent</key> | |
<array> | |
<dict> | |
<key>PayloadType</key> | |
<string>com.apple.applicationaccess</string> | |
<key>PayloadVersion</key> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum Pixel: Int { | |
case black = 0 | |
case white = 1 | |
case transparent = 2 | |
} | |
let width = 25 | |
let height = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Int { | |
func digits() -> [Int] { | |
var newN = self | |
var result: [Int] = [] | |
while newN > 0 { | |
let r = newN % 10 | |
newN = newN / 10 | |
result.append(r) | |
} | |
result.reverse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum GeometryErr: Error { | |
case InvalidDirection | |
case InvalidDistance | |
} | |
enum Direction { | |
case Up(_ distance: Int) | |
case Down(_ distance: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func calculate(_ inputs: [Int], _ idx: Int = 0) -> [Int] { | |
let opcode = inputs[idx] | |
if opcode == 99 { return inputs } | |
let x = inputs[inputs[idx+1]] | |
let y = inputs[inputs[idx+2]] | |
let out = inputs[idx+3] | |
var result : [Int] = inputs | |
switch opcode { | |
case 1: result[out] = x+y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func cost(_ mass: Int) -> Int { | |
return (mass/3) - 2 | |
} | |
func moduleCost(_ mass: Int, _ sum: Int = 0) -> Int { | |
let remainder = cost(mass) | |
let sum = sum + remainder | |
if cost(remainder) <= 0 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Example SwiftUI which synchronizes GUI toggles as booleans and stores them in UserDefaults | |
Mostly from the answer here: | |
https://stackoverflow.com/questions/56822195/how-do-i-use-userdefaults-with-swiftui | |
*/ | |
import SwiftUI | |
import Foundation | |
import Combine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"decorators": { | |
"load": [ | |
"SELECT uuid AS host_uuid FROM system_info;", | |
"SELECT hostname AS hostname FROM system_info;" | |
] | |
}, | |
"options": { | |
"logger_plugin": "gcs", | |
"host_identifier": "hostname", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"options": { | |
"logger_plugin": "dev_logger,gcplog", | |
"logger_path": "/tmp/osq.log", | |
"host_identifier": "specified", | |
"specified_identifier" : "groob.acme.co", | |
"config_plugin": "gist", | |
"schedule_splay_percent": 10 | |
}, | |
"schedule": { |
NewerOlder