Skip to content

Instantly share code, notes, and snippets.

@elmolm
elmolm / UserDefaultsAndStructsExtension.swift
Last active August 6, 2020 14:15
Save and load structs and struct arrays in UserDefaults
import Foundation
extension UserDefaults {
open func setStruct<T: Codable>(_ value: T?, forKey defaultName: String){
let data = try? JSONEncoder().encode(value)
set(data, forKey: defaultName)
}
open func structData<T>(_ type: T.Type, forKey defaultName: String) -> T? where T : Decodable {
guard let encodedData = data(forKey: defaultName) else {
@elmolm
elmolm / build.gradle
Created December 13, 2018 14:00
Java EE gradle template
plugins {
id 'war'
id 'eclipse'
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
@elmolm
elmolm / .bash_profile
Last active December 10, 2019 13:57
Reset all xcode simulators
...
alias sim_reset="echo -ne 'xcode simulator reset'; osascript -e 'tell application \"iOS Simulator\" to quit'; osascript -e 'tell application \"Simulator\" to quit'; xcrun simctl erase all; echo ' [OK]';";
...