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 / realm-helper.swift
Created February 14, 2015 07:23
Realm Helper
import Foundation
/**
Provides the default transaction block for perform a Realm transaction.
:param: block The block to perform the transaction. The realm is used to store the transaction.
*/
func realmTransaction(block: (realm: RLMRealm) -> Void) {
let realm = RLMRealm.defaultRealm()
@cbess
cbess / hapi-https.js
Last active August 29, 2015 14:19
hapi https
var options = {
tls: {
key: fs.readFileSync(path.join(__dirname, "private/key/key.pem"), 'utf-8'),
cert: fs.readFileSync(path.join(__dirname, "private/key/certificate.pem"), 'utf-8')
}
};
var https = new hapi.Server("localhost", configuration["api-port"], options);
var goodResult = ...
switch goodResult {
case let .Success(valueHere):
print("\(valueHere)")
default:
break
}
func myFunc() {
@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"
@cbess
cbess / perfectGod-readme.md
Last active April 9, 2018 14:14
PerfectGod.com links
@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 / 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 / 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
}