Skip to content

Instantly share code, notes, and snippets.

View groob's full-sized avatar
🌻

Victor Vrantchan groob

🌻
View GitHub Profile
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
<?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>
import Foundation
enum Pixel: Int {
case black = 0
case white = 1
case transparent = 2
}
let width = 25
let height = 6
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()
import Foundation
enum GeometryErr: Error {
case InvalidDirection
case InvalidDistance
}
enum Direction {
case Up(_ distance: Int)
case Down(_ distance: Int)
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
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 {
/**
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
{
"decorators": {
"load": [
"SELECT uuid AS host_uuid FROM system_info;",
"SELECT hostname AS hostname FROM system_info;"
]
},
"options": {
"logger_plugin": "gcs",
"host_identifier": "hostname",
{
"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": {