Skip to content

Instantly share code, notes, and snippets.

View herrkaefer's full-sized avatar

herrkaefer herrkaefer

View GitHub Profile
@herrkaefer
herrkaefer / colored_logger.py
Last active May 18, 2019 00:14
Simple Python colored logging with crayons
import logging
import crayons
# Define logging colors here
LOGGING_STYLES = {
'debug': {'color': 'white', 'bold': False},
'info': {'color': 'green', 'bold': True},
'warning': {'color': 'magenta', 'bold': True},
'error': {'color': 'yellow', 'bold': True},
@herrkaefer
herrkaefer / RealmHelper.swift
Created June 12, 2017 06:25
Realm object operations: update value in DB, delete from DB, ...
import RealmSwift
extension Object {
// Update property value in Realm
func update(_ property: String, value: Any?) {
let realm = try! Realm()
try! realm.write {
self.setValue(value, forKey: property)
}
}
#!/bin/bash
# Add a new note (format: markdown with Jekyll-like front matter)
# Usage: addnote.sh title category
# Author: herrkaefer (gloolar@gmail.com)
# Root directory of notes
notesdir="/Users/herrk/Dropbox/Notes"
# title is required
if [ -z "$1" ]