Skip to content

Instantly share code, notes, and snippets.

View AndresR173's full-sized avatar

Andres Rojas AndresR173

View GitHub Profile
@AndresR173
AndresR173 / CoreDataHelper.swift
Created November 14, 2019 17:53
CoreData helper based on generics implementation
//
// CoreDataHelper.swift
//
// Created by Andres Rojas on 14/11/19.
// Copyright © 2019 Andres Rojas. All rights reserved.
//
// MIT License
//
// Copyright (c) 2019 Andres Rojas
//
@AndresR173
AndresR173 / Coordinator.swift
Created November 20, 2019 15:38
Coordinator Pattern
//
// Coordinator.swift
// CoordinatorPatternDemo
//
// Created by Andres Rojas on 18/11/19.
// Copyright © 2019 Andres Rojas. All rights reserved.
//
import UIKit
@AndresR173
AndresR173 / RingAnimation.swift
Created November 21, 2019 14:00
Apple Watch ring animation based on DesignCode tutorials
//
// AnimatedRing.swift
// AnimatedRing
//
// Created by Andres Rojas on 21/11/19.
// Copyright © 2019 Andres Rojas. All rights reserved.
//
import SwiftUI
@AndresR173
AndresR173 / Builder.swift
Last active January 9, 2020 17:03
Builder Pattern
protocol Builder {
typealias Handler = (inout Self) -> Void
}
extension NSObject: Builder {}
extension Builder {
public func with(_ configure: Handler) -> Self {
var this = self
configure(&this)
@AndresR173
AndresR173 / Demo.swift
Created February 12, 2020 15:07 — forked from AliSoftware/Demo.swift
NestableCodingKey: Nice way to define nested coding keys for properties
struct Contact: Decodable, CustomStringConvertible {
var id: String
@NestedKey
var firstname: String
@NestedKey
var lastname: String
@NestedKey
var address: String
enum CodingKeys: String, NestableCodingKey {
@AndresR173
AndresR173 / UserDefaultsPropertyWrapper.swift
Created April 6, 2020 12:57
How to use User Defaults with Property Wrappers
import Foundation
@propertyWrapper
struct UserDefaultsWrapper<Value: Codable> {
let key: String
let defaultValue: Value
let userDefaults = UserDefaults(suiteName: Constants.kGroupIdentifier)
var wrappedValue: Value {
get {
@AndresR173
AndresR173 / TaskPropertyWrapper.swift
Created April 6, 2020 23:31
This example will show you how to use property wrappers to save Codable objects into UserDefaults
import Foundation
struct Task: Codable {
var title: String
var isDone: Bool
}
enum Errors: Error {
case encodeError
case decodeError
@AndresR173
AndresR173 / google-config.file.sh
Created July 26, 2020 20:35
Copy Google-Services.plist into Xcode project from Flutter projects
# Type a script or drag a script file from your workspace to insert its path.
environment=${ASSET_PREFIX}
# Name and path of the resource we're copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/Google/${environment}/${GOOGLESERVICE_INFO_PLIST}
# Make sure GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}"
@AndresR173
AndresR173 / dart.json
Last active May 7, 2021 17:48
VS Code - Dart Code Snippets
{
"triple_a_test": {
"prefix": "aaa",
"description": "AAA test",
"body": [
"test(",
"\t'should $1',",
"\t() async {",
"\t\t// arrange",
"\t\t$2",
@AndresR173
AndresR173 / main.dart
Created November 5, 2020 13:59
Generics, Futures, Extensions in Dart
void main() async {
//Dynamic List
var list = [];
list.add(1);
list.add('2');
print(list);
// Callbacks
void downloadImage(Function(int) callback) {
int progress = 0;