Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Cardona Rojas DanielCardonaRojas

View GitHub Profile
@DanielCardonaRojas
DanielCardonaRojas / Resolver.swift
Created Jan 7, 2021
Dependency injection for Swift projects
View Resolver.swift
@propertyWrapper
public struct Inject<Component> {
var component: Component
public init() {
self.component = Resolver.shared.resolve(Component.self)
}
public var wrappedValue: Component {
View TimeInterval+Extensions.swift
extension TimeInterval {
var milliseconds: Int {
return Int((truncatingRemainder(dividingBy: 1)) * 1000)
}
var seconds: Int {
return Int(self) % 60
}
var minutes: Int {
@DanielCardonaRojas
DanielCardonaRojas / logging.dart
Created Mar 24, 2020
Logging mixin for Dart and Flutter projects
View logging.dart
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 / UIViewExtensions.swift
Last active Dec 11, 2020
UIView general purpuse utilities.
View UIViewExtensions.swift
extension UIView {
func makeCircular() -> NSKeyValueObservation {
self.layer.cornerRadius = self.bounds.width/2
clipsToBounds = true
let observation = observe(\UIView.bounds, changeHandler: { this, change in
this.layer.cornerRadius = this.bounds.width/2
})
return observation
}
@DanielCardonaRojas
DanielCardonaRojas / circular_progress_border.dart
Created Nov 26, 2020
CircularProgressBorder flutter widget
View circular_progress_border.dart
import 'package:flutter/material.dart';
import 'dart:math';
class CircularProgressBorder extends StatelessWidget {
final Color backgroundColor;
final Color progressColor;
final Color unfilledColor;
final double progress;
final double thickness;
final double offset;
@DanielCardonaRojas
DanielCardonaRojas / dialog_controller.dart
Last active Oct 23, 2020
Flutter DialogController #flutter
View dialog_controller.dart
import 'dart:async';
import 'package:flutter/material.dart' as material;
import 'package:flutter/material.dart' show BuildContext, Widget, Navigator;
class DialogController {
final BuildContext context;
final Widget Function(BuildContext) builder;
Future<dynamic> value;
@DanielCardonaRojas
DanielCardonaRojas / git_log_format.awk
Last active Aug 5, 2020
git release notes #git #awk #release #notes
View git_log_format.awk
#! /usr/bin/awk -f
BEGIN {
FS="\][ ]*[-]*[ ]*"
}
/^\[.*\]/ {
sub(/\[/, "", $1)
if (NR == 1) {
previous_commit_tag = $1
commit_message = "\t- " $2
@DanielCardonaRojas
DanielCardonaRojas / MockURLProtocol.swift
Created Jul 31, 2020
MockURLProtocol useful for mocking URLSession #URLSession #Mock
View MockURLProtocol.swift
//
// MockURLProtocol.swift
// APIClientTests
//
// Created by Daniel Cardona Rojas on 31/07/20.
// Copyright © 2020 Daniel Cardona Rojas. All rights reserved.
//
import Foundation
@DanielCardonaRojas
DanielCardonaRojas / EZAction.swift
Created Jul 28, 2020
Add closure targets to UIControl subclasses.
View EZAction.swift
import UIKit
public typealias Action = (UIControl) -> Void
extension NSObject {
var uniqueId: String {
return String(describing: self)
}
}
@DanielCardonaRojas
DanielCardonaRojas / UIApplication+Extensions.swift
Created Jul 24, 2020
UIApplication extensions. Bundle marketing and build versions
View UIApplication+Extensions.swift
extension UIApplication {
static var appVersion: String? {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
}
static var buildVersion: String? {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
}
static var fullVersion: String? {
You can’t perform that action at this time.