Skip to content

Instantly share code, notes, and snippets.

View marcosgriselli's full-sized avatar

Marcos Griselli marcosgriselli

View GitHub Profile
@marcosgriselli
marcosgriselli / UIImage+Resize.swift
Last active February 2, 2024 07:04
UIImage Resize/Scaling
//
// UIImage+Resize.swift
//
// Created by Marcos Griselli on 6/9/17.
// Copyright © 2017 Marcos Griselli. All rights reserved.
//
import Foundation
import UIKit
@marcosgriselli
marcosgriselli / Canvas.swift
Created May 18, 2021 21:09
Simulate side-by-side Xcode Previews
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
PreviewsPlus.Canvas(
content: ContentView(),
previews: [
Preview(device: .iPhoneSE, colorScheme: .light, contentSizeCategory: .extraExtraExtraLarge),
Preview(device: .iPhone12Pro, colorScheme: .dark),
Preview(device: .iPhone12Pro, contentSizeCategory: .accessibilityExtraLarge, layoutDirection: .rightToLeft),
Preview(device: .iPhone12Pro, colorScheme: .dark, contentSizeCategory: .extraSmall, layoutDirection: .rightToLeft)
]
@marcosgriselli
marcosgriselli / ffmpeg-compress-mp4
Created January 19, 2021 12:19 — forked from lukehedger/ffmpeg-compress-mp4
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@marcosgriselli
marcosgriselli / AudioLoader.swift
Created October 2, 2017 04:21
Play an audio file from resources or .xcassets
import AVFoundation
var audioPlayer: AVAudioPlayer?
enum AudioLoader {
case fromResource(URL)
case fromAsset(NSDataAsset)
}
enum AudioLoaderError: Error {
case resourceNotFound
@marcosgriselli
marcosgriselli / ViewMorphing.swift
Created May 5, 2018 18:27
Morph a view to another view's via transforms or frame
//
// Morphable.swift
// Morphable
//
// Created by marcosgriselli on 05/05/2018.
// Copyright (c) 2018 marcosgriselli. All rights reserved.
//
import UIKit
import SwiftUI
struct ContentView: View {
var body: some View {
Text("I work!")
}
}
@marcosgriselli
marcosgriselli / BasicSearch.swift
Created April 21, 2018 21:39
Basic implementation of a UISearchController reusing the same type of UIViewController as the base and results.
import UIKit
protocol Searchable {
func update(text: String?)
}
class BaseSearchResultUpdating: NSObject, UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
guard let searchable = searchController.searchResultsController as? Searchable else {
fatalError("The searchResultsController is does not conform to Searchable.")
@marcosgriselli
marcosgriselli / bitrise.yml
Created December 17, 2018 22:41
Bitrise.yml configuration for ViewAnimator
---
format_version: '6'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: fastlane
app:
envs:
- FASTLANE_XCODE_LIST_TIMEOUT: '120'
- opts:
is_expand: false
FASTLANE_WORK_DIR: "."
@marcosgriselli
marcosgriselli / Array + Util.swift
Last active May 17, 2018 15:24
Array utility functions
import Foundation
// MARK: - Array
public extension Array {
/// Safe subscript for element at index
///
/// - Parameter index: array's index to subscript.
/// - Returns: Optional array element if it exists in that index.
public func item(at index: Int) -> Element? {
//
// ReusableCells.swift
// ella
//
// Created by Marcos Griselli on 12/17/17.
// Copyright © 2017 Hirsh Group LLC. All rights reserved.
//
import UIKit