Skip to content

Instantly share code, notes, and snippets.

View cbess's full-sized avatar
💭
Coding for Jesus' glory. Soli Deo gloria

C. Bess cbess

💭
Coding for Jesus' glory. Soli Deo gloria
View GitHub Profile
@cbess
cbess / TimeParts.swift
Last active May 5, 2023 07:59
Swift: Seconds to minutes and hours parts
/// Represents parts of time
struct TimeParts: CustomStringConvertible {
var seconds = 0
var minutes = 0
/// The string representation of the time parts (ex: 07:37)
var description: String {
return NSString(format: "%02d:%02d", minutes, seconds) as String
}
}
@cbess
cbess / NetworkFetcher.swift
Last active August 7, 2016 18:48
Custom network Fetcher that accepts a key, rather than using the URL.
//
// NetworkFetcher.swift
//
// Created by C. Bess on 8/7/16.
// Pulled from original NetworkFetcher (cleaned up and updated)
import Haneke
public class NetworkFetcher<T: DataConvertible>: Fetcher<T> {
let URL: NSURL
@cbess
cbess / RealmDataExtensions.swift
Created June 30, 2016 04:14
Helpul Realm extensions
extension List {
/// Return a new array from the List elements
func newArray() -> [T] {
var items = [T]()
for item in self {
items.append(item)
}
return items
}
@cbess
cbess / Log.swift
Last active September 2, 2021 07:25
Simple Logger class in Swift 4.x
import Foundation
/// Represents the Log facilities
struct Log {
/// Prints in debug only
static func debug(_ msg: String, line: Int = #line, fileName: String = #file, funcName: String = #function) {
#if DEBUG
let fname = (fileName as NSString).lastPathComponent
print("[\(fname) \(funcName):\(line)]", msg)
#endif
@cbess
cbess / AppNotify.swift
Last active August 10, 2019 15:58
Simple NSNotificationCenter wrapper for Swift 4.x
//
// AppNotify.swift
//
// Created by Christopher Bess on 6/30/15.
// MIT License
//
import Foundation
/// Represents the app notification.
@cbess
cbess / perfectGod-readme.md
Last active April 9, 2018 14:14
PerfectGod.com links
@cbess
cbess / nodejs-service.sh
Created November 29, 2015 07:52
Debian nodejs service script
#!/bin/sh
# tested on debian 6.x
NODE_ENV="production"
# the name for the pid and the log file, should be unique for the environment
FNAME="script-name"
APP_DIR="/var/webapps/example.com/src/nodejs"
NODE_APP="server.js"
PORT="7707"
var goodResult = ...
switch goodResult {
case let .Success(valueHere):
print("\(valueHere)")
default:
break
}
func myFunc() {