Skip to content

Instantly share code, notes, and snippets.

View DanielCardonaRojas's full-sized avatar

Daniel Cardona Rojas DanielCardonaRojas

View GitHub Profile
@DanielCardonaRojas
DanielCardonaRojas / XVimSetup.md
Created June 26, 2020 19:26
Xcode, iOS Dev, used snippets and commands
@DanielCardonaRojas
DanielCardonaRojas / iterable.dart
Created May 29, 2020 00:36
Function generators dart
import 'dart:async';
void main() {
var i = 20;
final fIterable = fibonacci(Fibonacci(0, 1));
fIterable.take(30).forEach((element) { print(element)});
print('fibonacci($i) = ${fibonacci(i)}');
@DanielCardonaRojas
DanielCardonaRojas / cache_first_repository.dart
Last active April 23, 2020 17:59
Repository definition
import 'package:dartz/dartz.dart';
abstract class Synchronizable extends Identifiable {
SyncronizedMark get syncStatus;
}
enum SyncronizedMark { synchronized, needsCreation, needsUpdate, needsDeletion }
class CacheFirstRepository<Entity extends Synchronizable>
@DanielCardonaRojas
DanielCardonaRojas / flutter_architecture.xml
Created March 26, 2020 17:30
Flutter Draw.io architecture
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="app.diagrams.net" modified="2020-03-26T17:30:01.852Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" etag="CozRrVWAEnlTrnrs07UZ" version="12.9.2" type="onedrive"><diagram id="t3-sszkKWpxtp2ijUWK8" name="Page-1">7Vtbd9o4EP41nG0fyME3Lo8Bkm3Obrc5ZbvdPnEUW2AlwnJlESC/fke2jLEliDcJcQ7pS4LGkpG+mfnmYtNyRov17xzF4WcWYNqyO8G65Yxbtm1bPQv+Sckmk3QHdiaYcxJkIqsQTMgDVsKOki5JgJPSRMEYFSQuC30WRdgXJRninK3K02aMlr81RnOsCSY+orr0OwlEmEn7XqeQf8JkHubfbHXUlQXKJytBEqKArXZEzkXLGXHGRPZpsR5hKsHLccnWXe65ut0Yx5Gos+DybvXp590Dub1cfO6vBl/+GP/1va3uco/oUh3421WK5iJmEdw4gcEHOPgci+SjOofY5OBwtowCLO9vtZzhKiQCT2Lky6srMAeQhWJB1WX1TZgLvN57BGsLDFgUZgss+Aam5AsGCstNbiRqvCpUY+V4hztq6SoZUtYw3966AAw+KMz+B362hp8GUiI4u9saj10GBYwilvMW67n0n7MZZSs/RFycoShiAgnCoqlcgyiZRzCR4hmcaUjRDabXLCFyAoh5dtZhzEgkML+4T3X3csC7ZeD7Ou6eAXbLOxbuTkfDGYORTtSQcRGyOYsQvSikw8JcOzAq5vzJWKywusVCbBQLoaVgZW0BWnzzr1x/5uXDH+p26WC8Lo02apTtVW7wMP5wHrbkPj50cMWBiINLH
@DanielCardonaRojas
DanielCardonaRojas / logging.dart
Created March 24, 2020 23:29
Logging mixin for Dart and Flutter projects
import 'dart:convert';
import 'package:logger/logger.dart';
import 'package:meta/meta.dart';
mixin Logging {
Logger _logger;
Logger get log {
return _logger ??= Logger(
@DanielCardonaRojas
DanielCardonaRojas / Builder.swift
Last active January 9, 2020 16:53
Builder pattern
import Foundation
public typealias Adapter<T> = (inout T) -> Void
public class BuilderHandler<V> {
let adapter: Adapter<V>
public init(_ handler: @escaping Adapter<V>) {
self.adapter = handler
}
@DanielCardonaRojas
DanielCardonaRojas / CarouselLayout.swift
Last active July 10, 2020 22:15
Reference to create custom layout for UICollectionView
//
// CarouselLayout.swift
// Spotit
//
// Created by Daniel Cardona Rojas on 10/12/19.
// Copyright © 2019 Daniel Cardona. All rights reserved.
//
import UIKit
@DanielCardonaRojas
DanielCardonaRojas / ComposableStyles.swift
Created November 20, 2019 16:30
A small DSL to group and compose styles for UIKit components.
//
// Style.swift
// ComposableStyles
//
// Created by Daniel Cardona Rojas on 20/11/19.
// Copyright © 2019 Daniel Cardona Rojas. All rights reserved.
//
import UIKit
@DanielCardonaRojas
DanielCardonaRojas / KeyPathAutolayout.swift
Last active November 15, 2019 18:20
Declarative KeyPath based Autolayout combinators
//
// KeyPathAutoLayout.swift
// Spotit
//
// Created by Daniel Cardona Rojas on 14/11/19.
// Copyright © 2019 Daniel Cardona Rojas. All rights reserved.
//
import UIKit
@DanielCardonaRojas
DanielCardonaRojas / UIImage+Letters.swift
Created November 5, 2019 22:19
Creates an image from initials. Use this with UIImageView
extension UIImage {
static func fromInitials(_ string: String, size: CGSize, backGroundColor: UIColor, textAttributes: [NSAttributedString.Key: Any]? = nil) -> UIImage? {
let text = string.initials
let scale = Float(UIScreen.main.scale)
UIGraphicsBeginImageContextWithOptions(size, false, CGFloat(scale))
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(backGroundColor.cgColor)
context?.fill(CGRect(x: 0, y: 0, width: size.width, height: size.height))