Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Cardona Rojas DanielCardonaRojas

View GitHub Profile
@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 / 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? {
@DanielCardonaRojas
DanielCardonaRojas / gen_ios_imgs.sh
Created Jul 16, 2020
Generate ios images from svg #svg #ios #png #images
View gen_ios_imgs.sh
# gen_ios_icons.sh
# Params: (filename) (width 1x) (height 1x)
# Get filename without an extension
filename=$1
filename_length=${#1}
name_length=$((filename_length-4))
name=${filename:0:$name_length}
mkdir $name
rsvg-convert -w $2 -h $3 $filename > $name/$name.png
rsvg-convert -w $((2*$2)) -h $((2*$3)) $filename > $name/$name@2x.png
@DanielCardonaRojas
DanielCardonaRojas / UIColor+Extension.swift
Created Jul 14, 2020
UIColor+Extensions #ios #swift #UIColor
View UIColor+Extension.swift
extension UIColor {
public convenience init?(hex: String) {
let r: CGFloat
let g: CGFloat
let b: CGFloat
let a: CGFloat
let start = hex.index(hex.startIndex, offsetBy: hex.hasPrefix("#") ? 1 : 0)
var hexColor = String(hex[start...])
if hexColor.count == 6 { hexColor += "FF" }
@DanielCardonaRojas
DanielCardonaRojas / generate_text_resource_class
Created Jul 9, 2020
Generate type safe class for localized strings #awk #iOS #Localized Strings
View generate_text_resource_class
#! /usr/bin/awk -f
BEGIN {
print "\
// This file is autogenerated do not modify\
\
import Foundation\
";
print "public struct TextResource {"
}
@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 / XVimSetup.md
Created Jun 26, 2020
Xcode, iOS Dev, used snippets and commands
View XVimSetup.md
@DanielCardonaRojas
DanielCardonaRojas / iterable.dart
Created May 29, 2020
Function generators dart
View iterable.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)}');
You can’t perform that action at this time.