Skip to content

Instantly share code, notes, and snippets.

View MarioIannotta's full-sized avatar

Mario Iannotta MarioIannotta

View GitHub Profile

Keybase proof

I hereby claim:

  • I am marioiannotta on github.
  • I am marioiannotta (https://keybase.io/marioiannotta) on keybase.
  • I have a public key ASAvS7fOYW6pCKTTkVZlT8bdVVAd2a8ljpRk1mLawk8GfQo

To claim this, I am signing this object:

#!/bin/sh
# https://gist.github.com/MarioIannotta/e27ac3ec067dc5b6f00c392d7527b10a
build_path="Builds/$(date '+%d-%m-%Y-%H-%M')"
target="YourFramework"
configuration="Your configuration eg: Release"
# clean up the build folder if already exists
rm -rf build_path
@MarioIannotta
MarioIannotta / Decodable+CustomDateFormat.swift
Last active February 3, 2021 06:07
A little extension to easily decode date with custom formats
import Foundation
var json = """
{
"lastSyncDate": "2018-10-28T09:03:59+0000",
"posts": [
{
"id": 0,
"title": "Swift 4 Codable: tips and tricks",
"link": "https://medium.com/@MarioIannotta/swift-4-codable-tips-and-tricks-7ab4674736d2",
@MarioIannotta
MarioIannotta / NilCoalescingOperator+
Created November 9, 2017 10:12
Use a.or(b) instead a ?? b
import Foundation
extension Optional {
func or(_ wrappedItem: Wrapped) -> Wrapped {
return self ?? wrappedItem
}
func or(_ wrappedItem: Optional) -> Optional {
return self ?? wrappedItem
import Foundation
extension String {
var stringToDateCustomMethod: Date {
return Date()
}
}
extension KeyedDecodingContainer {
subscript<T: Decodable>(key: KeyedDecodingContainer.Key) -> T? {
@MarioIannotta
MarioIannotta / DecodingUtils.swift
Last active September 23, 2017 09:25
Simple KeyedDecodingContainer subscript extension
extension KeyedDecodingContainer {
subscript<T: Decodable>(key: KeyedDecodingContainer.Key) -> T? {
return try? decode(T.self, forKey: key)
}
}
/*!
* Chart.js
* http://chartjs.org/
* Version: 2.7.0
*
* Copyright 2017 Nick Downie
* Released under the MIT license
* https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Chart = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,modul
@MarioIannotta
MarioIannotta / Test.swift
Last active August 22, 2016 08:49
Handle swift logs and testing safely and painless
/*
This gist is part of the post "Handle swift logs and testing safely and painless"
More info here:
https://medium.com/@MarioIannotta/handle-swift-test-and-log-safely-c825d6006bc4#.363uu3a94
*/
import Foundation
@MarioIannotta
MarioIannotta / MIUserDefault.swift
Last active July 21, 2016 12:35
Smooth NSUserDefault handling with Swift
enum MIUserDefault: String {
case persistentStuffOne = "persistentStuffOne"
case persistentStuffTwo = "persistentStuffTwo"
case persistentStuffThree = "persistentStuffThree"
func set(object: AnyObject) {
NSUserDefaults.standardUserDefaults().setObject(object, forKey: self.rawValue)
}
func get() -> AnyObject? {