View Fastfile
This file contains 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
desc "Change a value in xcodeproj file." | |
desc "Usage: fastlane change_build_value xcodeproj:<file-name> name:<build-setting> from:<old-value> to:<new-value>" | |
lane :change_build_value do |options| | |
xcodeproj = options[:xcodeproj] | |
name = options[:name] | |
from = options[:from] | |
to = options[:to] | |
optional_quotes = '"\\{0,1\\}' | |
replacement_expression = "s/#{name} = #{optional_quotes}#{from}#{optional_quotes};/#{name} = #{to};/g" |
View UserDefaultsPropertyWrapper.swift
This file contains 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 Foundation | |
/// Property wrapper for `UserDefaults.standard` backed value | |
@propertyWrapper | |
struct UserDefault<Value: UserDefaultsValue> { | |
let key: String | |
let defaultValue: Value | |
let container: UserDefaults |
View zoom-dl.sh
This file contains 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/sh | |
# courtesy of https://github.com/ytdl-org/youtube-dl/issues/23573#issuecomment-631115716 | |
url="${1%%\?*}" | |
jar=$(mktemp) | |
mp4=$(curl -s -c "$jar" "$url" | grep video/mp4 | grep -o 'https:[^"]*') | |
file=$(echo "$mp4" | grep -o "[^/? ]*\.mp4") | |
echo "Downloading $file" |
View FilteredList.swift
This file contains 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
// | |
// ContentView.swift | |
// Stacketude | |
// | |
// Created by Yonat Sharon on 06/01/2020. | |
// Copyright © 2020 Yonat Sharon. All rights reserved. | |
// | |
import SwiftUI |
View Binding+Extensions.swift
This file contains 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 SwiftUI | |
extension Binding { | |
/// Execute block when value is changed. | |
/// | |
/// Example: | |
/// | |
/// Slider(value: $amount.didSet { print($0) }, in: 0...10) | |
func didSet(execute: @escaping (Value) ->Void) -> Binding { | |
return Binding( |
View UISegmentedControl+Vertical.swift
This file contains 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
// | |
// UISegmentedControl+Vertical.swift | |
// Make a UISegmentedControl vertical by setting mySegmentedControl.vertical = true | |
// | |
// Created by Yonat Sharon on 14/9/14. | |
// Copyright (c) 2014 Yonat Sharon. All rights reserved. | |
// | |
import UIKit |
View String+substr.swift
This file contains 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 String { | |
/** | |
Perl style substring | |
- parameter offset: Negative offset starts that far back from the end of the string | |
- parameter length: Negative length leaves that many characters off the end of the string. Omit to return everything through the end of the string. | |
*/ | |
func substr(offset: Int, length: Int = 0) -> String { | |
let start = offset < 0 ? endIndex.advancedBy(offset, limit: startIndex) : startIndex.advancedBy(offset, limit: endIndex) | |
let end = length > 0 ? start.advancedBy(length, limit: endIndex) : endIndex.advancedBy(length, limit: startIndex) |
View BackgroundTaskWrapper.swift
This file contains 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
class BackgroundTaskWrapper { | |
private var taskID = UIBackgroundTaskIdentifier.invalid | |
var cancelAction: (() -> Void)? | |
func begin() { | |
guard .invalid == taskID else { return } | |
taskID = UIApplication.shared.beginBackgroundTask { [weak self] in | |
self?.cancelAction?() | |
self?.end() | |
} |
View FBSDKGraphRequest+Paging.h
This file contains 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
// | |
// FBSDKGraphRequest+Paging.h | |
// Facebook Paging Extension | |
// | |
// Created by Yonat Sharon on 04.04.2016. | |
// Copyright © 2016 Yonat Sharon. All rights reserved. | |
// | |
#import <FBSDKCoreKit/FBSDKCoreKit.h> |
View ask.swift
This file contains 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
/// Show an OK/Cancel modal box that works in both iOS 7 and iOS 8 | |
func ask(title: String, #message: String, #completion: (answer: Bool) -> Void) { | |
if nil != objc_getClass("UIAlertController".UTF8String) { // use UIAlertController | |
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert) | |
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action) -> Void in | |
completion(answer: false) | |
}) | |
let okayAction = UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in | |
completion(answer: true) | |
}) |
NewerOlder