Skip to content

Instantly share code, notes, and snippets.

View eMdOS's full-sized avatar

Emilio Ojeda eMdOS

  • Zapopan, Jalisco
View GitHub Profile
@eMdOS
eMdOS / RecordAudio.swift
Created August 3, 2017 21:22 — forked from hotpaw2/RecordAudio.swift
Swift 3.0 Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift 3.0 class
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16. Updated 2017Feb07
// Copyright © 2017 HotPaw Productions. All rights reserved.
@eMdOS
eMdOS / UIKit.UIStoryboard.swift
Last active August 15, 2017 18:45
Safe View Controller instances from Storyboards
@available(iOS 5.0, *)
open class UIStoryboard : NSObject {
public /*not inherited*/ init(name: String, bundle storyboardBundleOrNil: Bundle?)
open func instantiateInitialViewController() -> UIViewController?
open func instantiateViewController(withIdentifier identifier: String) -> UIViewController
}
@eMdOS
eMdOS / carthage.sh
Last active September 27, 2017 21:58
Carthage: update | bootstrap ... from bash
#!/bin/bash
update="update"
bootstrap="bootstrap"
expectation_message="EXPECTED: [ $update | $bootstrap ]"
if [ $# -eq 0 ]; then
echo "ERROR: No argument supplied."
echo $expectation_message
@eMdOS
eMdOS / git_cache_reset.md
Created November 28, 2017 15:31
.gitignore + git cache reset

Removing the cache:

git rm -r --cached .

Adding files:

git add .

Commiting changes:

@eMdOS
eMdOS / doc.md
Created January 10, 2018 22:54
[Swift] URL: ExpressibleByStringLiteral

Extension:

extension URL: ExpressibleByStringLiteral {
    public init(stringLiteral value: StaticString) {
        guard let url = URL(string: "\(value)") else {
            fatalError("Invalid URL string literal: \(value)")
        }
        self = url
 }
@eMdOS
eMdOS / Equatable.swift
Created January 11, 2018 01:02
[Swift] Expressively matching a Value againts a Sequence
public extension Equatable {
func isAny(of candidates: Self...) -> Bool {
return candidates.contains(self)
}
}
@eMdOS
eMdOS / README.md
Created February 6, 2018 20:41
macOS Dock - Most recent apps
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'
killall Dock
@eMdOS
eMdOS / DOC.md
Last active July 18, 2018 21:02
Localization (Protocol-Oriented Programming approach)

Examples

  1. Getting the signInButton value from Common.strings file.
Strings.Common.signInButton.localized
@eMdOS
eMdOS / CGSize.swift
Created July 30, 2018 19:32
CGSize Scaling
extension CGSize {
func widthScaling(with value: CGFloat) -> CGSize {
return CGSize(width: value, height: (value * height) / width)
}
func heightScaling(with value: CGFloat) -> CGSize {
return CGSize(width: (value * width) / height, height: value)
}
}
@eMdOS
eMdOS / ResultType.swift
Created October 31, 2018 18:59
ResultType
import Foundation
public enum ResultType<Value> {
case success(Value)
case failure(Swift.Error)
}
extension ResultType {
public init(value: () throws -> Value) {
do {