This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p caf | |
for file in $1*; do | |
file_basename=$(basename -- "$file") | |
filename="${file_basename%.*}" | |
echo converting $filename | |
afconvert -f caff -d LEI16@44100 -c 1 $file caf/$filename.caf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RxCocoa | |
import RxSwift | |
public extension Reactive where Base: UISearchController { | |
var delegate: DelegateProxy<UISearchController, UISearchResultsUpdating> { | |
return RxSearchResultsUpdatingProxy.proxy(for: base) | |
} | |
var searchPhrase: Observable<String> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RxCocoa | |
import RxSwift | |
extension Reactive where Base: UITextField { | |
var isSecureTextEntry: Binder<()> { | |
return Binder(base, binding: { (textField, _) in | |
textField.isSecureTextEntry = !textField.isSecureTextEntry | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension BinaryFloatingPoint { | |
/// Returns normalized value for the range between `a` and `b` | |
/// - Parameters: | |
/// - min: minimum of the range of the measurement | |
/// - max: maximum of the range of the measurement | |
/// - a: minimum of the range of the scale | |
/// - b: minimum of the range of the scale | |
func normalize(min: Self, max: Self, from a: Self = 0, to b: Self = 1) -> Self { | |
(b - a) * ((self - min) / (max - min)) + a | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
given a and m, function finds x for a * x = 1 (mod m) | |
24 * x = 1 (mod 5) | |
24 = x*exp(-1) (mod 5) | |
x = 4 | |
modInverse(a: 24, m: 5) returns optional(4) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func gcd(_ p: Int, _ q: Int) -> Int { | |
if q == 0 { | |
return p | |
} | |
return gcd(q, p % q); | |
} |