Skip to content

Instantly share code, notes, and snippets.

View jaanussiim's full-sized avatar

Jaanus Siim jaanussiim

View GitHub Profile
@jaanussiim
jaanussiim / ConcurrentOperation.swift
Last active December 31, 2020 12:30
ConcurrentOperation operation copied to every project
/*
* Copyright 2020 Coodly LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jaanussiim
jaanussiim / gist:edc8c8e994cc344aae402aca936dd609
Created May 3, 2018 11:50
DictionaryDecoder - close to insanity?
internal class DictionaryDecoder: JSONDecoder {
func decode<T>(_ type: T.Type, from dictionary: Any) throws -> T where T : Decodable {
let jsonData = try JSONSerialization.data(withJSONObject: dictionary, options: [])
return try decode(T.self, from: jsonData)
}
}
let monospaced = UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: .bold)
let fontMetrics = UIFontMetrics(forTextStyle: .body)
runtime.font = fontMetrics.scaledFont(for: monospaced)
@jaanussiim
jaanussiim / gist:3597754
Created September 2, 2012 12:03
Script for automated mogeneration execution in Xcode
PATH_TO_MODELD="mTimer.xcdatamodeld"
OUTPUT_PATH="Classes"
type mogenerator >/dev/null 2>&1 || {
echo >&2 "warning: mogenerator not found. You will need it when changing core data model";
exit 0;
}
CURRENT_VERSION=$(/usr/libexec/PlistBuddy -c "Print :_XCCurrentVersionName" "${PATH_TO_MODELD}/.xccurrentversion")